Skip to content

Build: Move type checking and test suites to tox - #4494

Open
oresttokovenko wants to merge 2 commits into
apache:mainfrom
oresttokovenko:tox-typecheck-and-tests
Open

oresttokovenko wants to merge 2 commits into
apache:mainfrom
oresttokovenko:tox-typecheck-and-tests

Conversation

@oresttokovenko

@oresttokovenko oresttokovenko commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What

This PR moves mypy type checking and the test suites out of Makefile and .pre-commit-config.yaml into a dedicated tox.toml, backed by tox-uv-bare (uv-venv-lock-runner) and PEP 735 [dependency-groups] in pyproject.toml. Makefile stays for setup, linting, docs, interactive notebooks, and clean; prek stays for formatting and fast linters.

  • Adds tox.toml with default env_list (typecheck and test-3.11–test-3.14) plus unit, integration, s3, adls, gcs, notebook, and coverage
  • Adds PEP 735 [dependency-groups] (lint, tox, types, coverage) in pyproject.toml and updates uv.lock, so every tox environment installs strictly from uv.lock
  • Removes mirrors-mypy from .pre-commit-config.yaml
  • Removes test/coverage targets from Makefile (retaining install*, lint, check-license, docs-*, notebook*, clean)
  • Updates .github/workflows/python-ci.yml, .github/workflows/python-integration.yml, dev/release/verify_rc.sh, MANIFEST.in, dev/.rat-excludes, AGENTS.md, mkdocs/docs/contributing.md, and mkdocs/docs/verify-release.md

Why

Following the Nov 24 community sync, this scopes the tooling cleanup down from #4208 to just testing and type checking using tox (rather than replacing Makefile and prek wholesale with nox and just).

Previously, test and type-checking logic was split across Makefile, .pre-commit-config.yaml, and the CI workflows:

  • mirrors-mypy pinned mypy and its types-* stubs outside pyproject.toml/uv.lock, so Dependabot's uv ecosystem did not bump them and local uv run could not reproduce the isolated CI mypy environment
  • CI duplicated platform workarounds (such as --no-extra hive-kerberos on Windows) and uv sync/pytest/coverage invocations across workflows and Makefile
  • With tox.toml + uv-venv-lock-runner, CI and local runs invoke the same environments with the same locked dependencies from uv.lock, and typecheck runs as its own fast job instead of hiding behind matrix.python == '3.11'

Where the old recipes and checks live now

Old command / hook Command now
mirrors-mypy (prek) uv run tox -e typecheck
make test uv run tox -e unit (or uv run tox -p for 3.11–3.14)
make test PYTEST_ARGS="..." uv run tox -e unit -- ...
make test-integration uv run tox -e integration (KEEP_COMPOSE=1 to keep containers up)
make test-s3 / test-adls / test-gcs uv run tox -e s3 / adls / gcs
make test-notebook uv run tox -e notebook
make coverage-report uv run tox -e coverage
make test-coverage COVERAGE=1 uv run tox -e unit,integration,s3,adls,gcs,coverage

make install, make lint, make check-license, make docs-serve, make docs-build, make notebook, make notebook-infra, and make clean remain in Makefile

Tests

  • uv lock --check passed
  • COVERAGE=1 COVERAGE_FAIL_UNDER=0 uv run --locked --only-group tox tox run -r -e typecheck,test-3.13,coverage -- tests/avro/test_decoder.py passed (typecheck: 0 issues across 222 files; test-3.13: 68 passed; coverage: combined and reported)
  • uv run --locked --only-group tox tox run --notest -e unit synced cleanly from uv.lock
  • uv run --locked --only-group lint prek run -a passed all 10 remaining hooks
  • zizmor reported 0 findings on .github/workflows/python-ci.yml and .github/workflows/python-integration.yml

@Fokko

Fokko commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Thanks @oresttokovenko for raising this PR, and joining the PyIceberg sync the other day. Sorry for the reviewing taking some time, but I wanted to take the time to dive into it, and let it sink in a bit.

I hate to be that guy that dismisses changes, but I want to make sure that we're heading into the right direction. Couple of things:

  • I'm hesitant of dropping the Makefile commands, since folks might rely on it in their infra. I think also that make test is easier to guess or remember than uv run tox -e unit.
  • Why the choice of tox? I know tox from back in the days, and I my personal experiences have been far from optimal. For example, for isolation, I think that Docker is a far better alternative. Beside that, I know that there is a lot of tooling out there, and picking one of them isn't easy. Looking at the downloads (not the best metric, I know), it seems that the glory days of tox are in the past: https://pypistats.org/packages/tox?smooth=true
  • Finally, I'd rather would like to see that we replace tools, rather than add new ones. Tox and uv have a certain overlap, wouldn't we be able to do everything in uv? Starting fixing the type-checker?

Again, I would also like to invite others to get their opinion.

@oresttokovenko

oresttokovenko commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@Fokko thank you for the review!

  • I'm hesitant of dropping the Makefile commands, since folks might rely on it in their infra. I think also that make test is easier to guess or remember than uv run tox -e unit.

Makes sense, I'm happy to keep thin Makefile wrappers (like make test calling uv run tox -e unit) so muscle memory keep working for those folks that use it. I also moved the Docker container setup back into Makefile so tox only manages Python environments, tests, typechecking, and coverage as was originally intended. The reason I'd prefer using the tox CLI directly still gives more flexibility when you want it, like uv run tox -p across installed Pythons, chaining environments with -e test-3.12,typecheck, or passing pytest flags straight after --, etc, although we can have both the Makefile recipe and the direct commands if needed, plus agents don't care about wrappers 😅

  • Why the choice of tox? I know tox from back in the days, and I my personal experiences have been far from optimal. For example, for isolation, I think that Docker is a far better alternative. Beside that, I know that there is a lot of tooling out there, and picking one of them isn't easy. Looking at the downloads (not the best metric, I know), it seems that the glory days of tox are in the past: https://pypistats.org/packages/tox?smooth=true

3 part answer:

  1. As far as tox itself, we can discuss the values of each tool at length but I picked it because it's mature enough for an ASF project (other ASF Python projects like Flink, Beam, and Paimon use it) and solves the fragmented test and typecheck setup across Make and CI. It is the very uncontroversial choice, I assure you. I'm not wedded to tox specifically, so if you have another tool in mind that solves the same problem better I'm open to it.

  2. Docker does provide isolation but much more than is needed here, and it's too heavy for fast local mypy and unit-test runs across Python versions, so I would argue it' s not the right choice for python dev related tasks

  3. This chart looks back at the last 120 days so I'm not sure if there's anything valuable to gather from that time period, on the other hand tox is used by over 120,000+ projects, including ASF like I mentioned - https://github.com/tox-dev/tox/network/dependents?dependent_type=REPOSITORY

  • Finally, I'd rather would like to see that we replace tools, rather than add new ones. Tox and uv have a certain overlap, wouldn't we be able to do everything in uv? Starting fixing the type-checker?

Replacing everything in one shot is tough to get reviewed in practice, and I want to create PRs that are easy to understand and review, and not ask maintainers to take huge risks when smaller risks are safer. This is a path to consolidating tooling in the long run, so I would think it's beneficial to the project as a whole.

uv is a dependency manager, while tox (via tox-uv) is a test runner that delegates environment creation and locking to uv, so they complement rather than duplicate each other. I did look into this, and there is a way, via uv run --isolated to create a fresh ephemeral venv on every run (re-running the editable/Cython install), but tox-uv is a more elegant solution and keeps cached isolated environments per Python version and task without overwriting the main .venv, but one day uv may replace tox too, I'd welcome that change.

Regarding the type checker, I'm also working on that! I opened this issue and mentioned it during our last python sync but it still hasn't received any feedback. That issue relates to this PR because type checking is currently broken and integrating it into nox would be a great way to incrementally improve it (it would be harder via the current approach with prek due to how it manages dependencies)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants