Skip to content

Commit

Permalink
Update Python version in workflows and add typing features
Browse files Browse the repository at this point in the history
* Updated `pylint.yml` workflow file to use only Python versions 3.8+
* Added support for TypedDict and Literal types in `__init__.py` (Python 3.9+)
* Fall back to using `typing_extensions` for older Python versions

This commit ensures that our code is compatible with the latest Python versions while still supporting older versions.
  • Loading branch information
cr2007 committed Jun 4, 2024
1 parent d15b123 commit 857a02f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
11 changes: 5 additions & 6 deletions cambai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
import math
import json
from time import sleep
from typing import Optional
from typing import Optional, Literal, TypedDict
from enum import IntEnum
import requests
from rich import print
from tqdm import tqdm

if sys.version_info >= (3, 8):
# Python 3.8+ supports the built-in TypedDict and Literal types
from typing import Literal, TypedDict
else:
from typing_extensions import Literal, TypedDict
# Check the Python version at runtime
if sys.version_info < (3, 9):
# For Python versions less than 3.9, import Literal and TypedDict from typing_extensions
from typing import List as list


class APIKeyMissingError(Exception):
"""Exception raised when the API Key is missing."""

Expand Down

0 comments on commit 857a02f

Please sign in to comment.