diff --git a/.github/workflows/python.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/python.yml rename to .github/workflows/ci.yml index 505365e..e06070a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,8 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python application +name: CI on: push: - branches: [ "master" ] + branches: [ "master", "ci/*" ] pull_request: branches: [ "master" ] @@ -13,10 +10,12 @@ permissions: contents: read jobs: - build: - + test: + name: ${{ matrix.name || matrix.python }} runs-on: ubuntu-latest - + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: Setup Go environment @@ -29,20 +28,19 @@ jobs: distribution: temurin java-version: 22 cache: maven - - name: Set up Python 3.10 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' - cache: pip + python-version: ${{ matrix.python-version }} + allow-prereleases: true + check-latest: true - name: Install dependencies run: | sudo apt install libmaxminddb0 libmaxminddb-dev python -m pip install --upgrade pip - pip install ".[test,dev]" - - name: Check with ruff - run: | - ruff check - ruff format --check - - name: Test with pytest - run: | - pytest + pip install tox + - name: test + run: tox -e py + - name: lint + if: matrix.python-version == '3.12' + run: tox -e lint \ No newline at end of file diff --git a/mmdb_writer.py b/mmdb_writer.py index 87e59cb..67fcc8d 100644 --- a/mmdb_writer.py +++ b/mmdb_writer.py @@ -23,7 +23,7 @@ def __init__(self, value: float): class MmdbF64(MmdbBaseType): - def __init__(self, value: Union[float | Decimal]): + def __init__(self, value: Union[float, Decimal]): super().__init__(value) @@ -145,14 +145,14 @@ def __repr__(self): "uint64", "uint128", "int32", - ] - | MmdbU16 - | MmdbU32 - | MmdbU64 - | MmdbU128 - | MmdbI32 + ], + MmdbU16, + MmdbU32, + MmdbU64, + MmdbU128, + MmdbI32, ] -FloatType = Union[Literal["f32", "f64", "float32", "float64"] | MmdbF32 | MmdbF64] +FloatType = Union[Literal["f32", "f64", "float32", "float64"], MmdbF32, MmdbF64] class Encoder: @@ -547,7 +547,7 @@ def __init__( ip_version=4, database_type="GeoIP", languages: List[str] = None, - description: Union[Dict[str, str] | str] = "GeoIP db", + description: Union[Dict[str, str], str] = "GeoIP db", ipv4_compatible=False, int_type: IntType = "auto", float_type: FloatType = "f64", diff --git a/pyproject.toml b/pyproject.toml index e6ee08a..26cc444 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "mmdb_writer" description = "Make `mmdb` format ip library file which can be read by maxmind official language reader" readme = "README.md" license = {file = "LICENSE"} -requires-python = ">=3.6" +requires-python = ">=3.8" keywords = ["mmdb", "maxmind"] authors = [{ name = "VimT", email = "me@vimt.me" } ] classifiers = [ @@ -16,8 +16,9 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c9afab4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = + py3{13,12,11,10,9,8} + lint +skip_missing_interpreters = true + +[testenv] +description = run unit tests +extras = test +commands = pytest + +[testenv:lint] +extras = dev +commands = + ruff check --no-fix + ruff format --check