From b5be922929e625221c553956759f8a8b6db4288c Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 8 May 2025 07:06:51 -0700 Subject: [PATCH 1/4] Reorder config sections --- pyproject.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ba0feb2f..79ea2e85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,17 @@ requires = [ ] build-backend = "setuptools.build_meta" +[project.urls] +Homepage = "https://www.maxmind.com/" +Documentation = "https://geoip2.readthedocs.org/" +"Source Code" = "https://github.com/maxmind/GeoIP2-python" +"Issue Tracker" = "https://github.com/maxmind/GeoIP2-python/issues" + +[tool.black] +# src is showing up in our GitHub linting builds. It seems to +# contain deps. +extend-exclude = '^/src/' + [tool.ruff.lint] select = ["ALL"] ignore = [ @@ -78,14 +89,3 @@ ignore = [ [tool.setuptools.package-data] geoip2 = ["py.typed"] - -[project.urls] -Homepage = "https://www.maxmind.com/" -Documentation = "https://geoip2.readthedocs.org/" -"Source Code" = "https://github.com/maxmind/GeoIP2-python" -"Issue Tracker" = "https://github.com/maxmind/GeoIP2-python/issues" - -[tool.black] -# src is showing up in our GitHub linting builds. It seems to -# contain deps. -extend-exclude = '^/src/' From 90ad53eb1f5540c0ecb51bb1f66b5a85ce3464e6 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 8 May 2025 07:12:55 -0700 Subject: [PATCH 2/4] Modernize tox config and switch to tox-gh --- .github/workflows/test.yml | 45 +++++++++++++++++++------------------- pyproject.toml | 41 ++++++++++++++++++++++++++++++++++ setup.cfg | 38 -------------------------------- 3 files changed, 63 insertions(+), 61 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c05fa29a..5ad5ffe9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,32 +9,31 @@ on: permissions: {} jobs: - build: - + test: + name: test with ${{ matrix.env }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - platform: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] - python-version: [3.9, "3.10", 3.11, 3.12, 3.13] - - name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} - runs-on: ${{ matrix.platform }} - + env: [3.9, "3.10", 3.11, 3.12, 3.13] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: submodules: true persist-credentials: false - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools tox tox-gh-actions - - - name: Test with tox - run: tox + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh + - name: Install Python + if: matrix.env != '3.13' + run: uv python install --python-preference only-managed ${{ matrix.env }} + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.env }} + - name: Run test suite + run: tox run --skip-pkg-install + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.env }} diff --git a/pyproject.toml b/pyproject.toml index 79ea2e85..6516ed4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ dev = [ ] lint = [ "black>=25.1.0", + "flake8>=7.2.0", "mypy>=1.15.0", "pylint>=3.3.6", "ruff>=0.11.6", @@ -89,3 +90,43 @@ ignore = [ [tool.setuptools.package-data] geoip2 = ["py.typed"] + +[tool.tox] +env_list = [ + "3.9", + "3.10", + "3.11", + "3.12", + "3.13", + "lint", +] +skip_missing_interpreters = false + +[tool.tox.env_run_base] +dependency_groups = [ + "dev", +] +commands = [ + ["pytest", "tests"], +] + +[tool.tox.env.lint] +description = "Code linting" +python = "3.13" +dependency_groups = [ + "dev", + "lint", +] +commands = [ + ["black", "--check", "--diff", "."], + ["flake8", "geoip2"], + ["mypy", "geoip2", "tests"], + ["pylint", "geoip2"], +] + +[tool.tox.gh.python] +"3.13" = ["3.13", "lint"] +"3.12" = ["3.12"] +"3.11" = ["3.11"] +"3.10" = ["3.10"] +"3.9" = ["3.9"] diff --git a/setup.cfg b/setup.cfg index 6f275efc..c88d6d40 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,41 +7,3 @@ geoip2 = py.typed [pylint.message_control] disable = duplicate-code - -[tox:tox] -envlist = {py39,py310,py311,py312,py313}-test,py313-{black,lint,flake8,mypy} - -[gh-actions] -python = - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 - 3.13: py313,black,lint,flake8,mypy - -[testenv:{py38,py39,py310,py311,py312,py313}-test] -deps = - pytest-httpserver - pytest -commands = pytest tests - -[testenv:py313-black] -deps = black -commands = black --check --diff . - -[testenv:py313-lint] -deps = pylint -commands = pylint geoip2 - -[testenv:py313-flake8] -deps = flake8 -commands = flake8 geoip2 - -[testenv:py313-mypy] -deps = - mypy - pytest_httpserver - pytest - types-requests - voluptuous-stubs -commands = mypy geoip2 tests From a81791688b479ab9a2926500762bff22528f6307 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 8 May 2025 07:14:53 -0700 Subject: [PATCH 3/4] Remove setuptools option that is in pyproject.toml --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index c88d6d40..d7634046 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,8 +2,5 @@ # black uses 88 : ¯\_(ツ)_/¯ max-line-length = 88 -[options.package_data] -geoip2 = py.typed - [pylint.message_control] disable = duplicate-code From 8d1c934a9370aff4b75cd5aa7c658cb312f8f87d Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 8 May 2025 07:16:43 -0700 Subject: [PATCH 4/4] Move pylint config to pyproject.toml --- pyproject.toml | 3 +++ setup.cfg | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6516ed4f..f9e1e527 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,9 @@ Documentation = "https://geoip2.readthedocs.org/" # contain deps. extend-exclude = '^/src/' +[tool.pylint."MESSAGES CONTROL"] +disable = "duplicate-code" + [tool.ruff.lint] select = ["ALL"] ignore = [ diff --git a/setup.cfg b/setup.cfg index d7634046..a8d46884 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ [flake8] # black uses 88 : ¯\_(ツ)_/¯ max-line-length = 88 - -[pylint.message_control] -disable = duplicate-code