Skip to content

Modernize codebase to Python 3.10+ - #332

Merged
ewels merged 3 commits into
mainfrom
modernize-python-3.10
Aug 12, 2026
Merged

ewels merged 3 commits into
mainfrom
modernize-python-3.10

Conversation

@ewels

@ewels ewels commented Jun 2, 2026 •

Copy link
Copy Markdown
Owner

Slightly more controversial PR.. Opening at least partially just for discussion.

Drops support for Python 3.8 and 3.9 (now both EOL); minimum is now Python 3.10. This allows us to clean up the code quite a bit:

  • Typing syntax: PEP 604 unions (X | None instead of Optional/Union) and PEP 585 builtin generics (list, dict, tuple, type) throughout, with ABCs imported from collections.abc.
  • Removed shims that only existed for Python <3.10:
    • the entry_points() 3.7 compat wrapper in cli.py
    • the Concatenate/ParamSpec typing_extensions fork in decorators.py
    • the &lt;3.9 skip in tests/test_types.py
  • Tooling: added the UP (pyupgrade) ruff rule and set ruff/pyright targets to py310.
  • CI: dropped 3.8/3.9 from the test matrices (pytest, scheduled-tests, test-examples).
  • Misc: subprocess.run(stdout=PIPE, stderr=PIPE) → capture_output=True in test helpers.

Merged main in, which resolved against the dev-tooling overhaul that landed since this branch was opened:

  • The pre-commit → prek switch: .pre-commit-config.yaml and the old workflow are gone, and prek.toml already pins a newer ruff than this branch bumped to.
  • Dev/docs requirements moved to dependency groups, so the optional-dependencies edits here are obsolete; the dev group's mypy marker is simplified now that the floor is 3.10.
  • [tool.black] dropped (main replaced Black with ruff format), and the warn_unused_ignores = false workaround is no longer needed — the dev group pins mypy>=2.3, so a single set of # type: ignores no longer has to span several mypy versions.
  • Kept main's versions of the RichContext.__enter__/__exit__ removal and the panel table filtering fix.
  • RichHelpFormatter.write_dl takes Iterable again, to stay compatible with the click supertype.

prek run -a and the test suite pass, on the dev env (3.11) and on 3.10.

🤖 Generated with Claude Code

@ewels
ewels requested a review from dwreeves June 2, 2026 22:51
@dwreeves

dwreeves commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Not too controversial, end of life is end of life and rich-click has been overly generous about supporting old Python versions. I'll look over this weekend but I imagine it's pretty straightforward.

Drop support for Python 3.8 and 3.9; minimum is now Python 3.10.

- Adopt PEP 604 unions (`X | None`) and PEP 585 builtin generics
  (`list`, `dict`, `tuple`, `type`) throughout, importing ABCs from
  `collections.abc`.
- Remove version-conditional shims for Python <3.10: the `entry_points`
  3.7 compat wrapper, the `Concatenate`/`ParamSpec` typing fork, and the
  `<3.9` skip in the type tests.
- Add the `UP` (pyupgrade) ruff rule; bump ruff to v0.15.15 and set
  black/ruff/pyright targets to py310.
- Set `warn_unused_ignores = false` so one set of `# type: ignore`s works
  across mypy >=1.14.1, and drop the CI `mypy<1.16` pin (was only needed
  for Python 3.8).
- Drop 3.8/3.9 from CI matrices; tidy `subprocess.run` to `capture_output`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ewels
ewels force-pushed the modernize-python-3.10 branch from 34602d0 to bccbdb0 Compare June 3, 2026 06:10
Reassigning the typed headers/rows variables to zip() tuples broke their
declared list types. Use an explicit branch that preserves the list types.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@dwreeves dwreeves left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me.

The one thing I would say is that removing support for a Python version makes more sense to me as a minor version release, not a patch release, so this should correspond with that.

Resolve conflicts with the dev-tooling overhaul on main:

- pre-commit → prek: drop `.pre-commit-config.yaml` and the old workflow;
  main's `prek.toml` already pins a newer ruff than this branch did.
- Dev/docs requirements now live in dependency groups, so the
  `optional-dependencies` edits here are obsolete. Simplified the dev group's
  `mypy` marker now that the floor is Python 3.10.
- Dropped `[tool.black]` (main replaced Black with `ruff format`) and the
  `warn_unused_ignores = false` workaround (the dev group pins mypy >=2.3, so
  a single set of ignores no longer has to span several mypy versions).
- Kept the modernised annotations in the source files, and took main's
  versions of the `RichContext.__enter__`/`__exit__` removal and the panel
  table filtering fix.
- `RichHelpFormatter.write_dl` takes `Iterable` again to stay compatible with
  the click supertype.
@ewels

ewels commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

Thanks for checking this over @dwreeves

Let's merge this in. Feels like a nice complement to the dev tooling updates, and good to get it all done in one pass (more or less).

@ewels
ewels merged commit 407e783 into main Aug 12, 2026
278 checks passed
@ewels
ewels deleted the modernize-python-3.10 branch August 12, 2026 06:29
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.

3 participants