Skip to content

Pyupgrade - #416

Draft
rwb27 wants to merge 3 commits into
mainfrom
pyupgrade
Draft

rwb27 wants to merge 3 commits into
mainfrom
pyupgrade

Conversation

@rwb27

@rwb27 rwb27 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

This adds the UP ruleset to ruff which updates old code to take advantage of new features. It made a bunch of code changes, which I've checked - mostly importing things from the canonical place (e.g. Callable comes from collections.abc and not typing now), and also changes like Optional[T] -> T | None.

I think it does a few things that are useful, and also makes the code more self-consistent.

I notice it's removed a bunch of quotation marks from some type hints. This does not seem to displease either the test suite or mypy so I assume I was just being overly cautious by quoting them.

this is not ready for merge

This touches a lot of code. My process was:

  • Turn on the UP ruleset
  • Apply all fixes, including "unsafe"
  • Manually check all changes
  • Verify mypy and pytest still pass

That means all the automated changes have had one human review already. However, it's going to be a rebase nightmare. I suggest that, when we reach a point where we've got minimal open PRs, we re-do this PR and merge it quickly. I guess in principle one could apply the auto-fixes to every commit in one of the branches before rebasing, to minimise conflicts: I've not done that and feel like it will be painful even with automation, so it's probably best to minimise the number of times it happens...

rwb27 added 3 commits November 2, 2026 21:22
I've excepted the CLI and test suite from this, because they have good reasons
for print statements.
The UP ruleset upgrades old code to do things like `Optional[int]` -> `int | None` and so on.

This required a bunch of code changes, none of which should have any effect.
@rwb27
rwb27 marked this pull request as draft November 3, 2026 10:03

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.

1 participant