Upgrade all files to Python 3.7+ syntax #486
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pyupgrade
is a tool similar toblack
andisort
that auto-formats code to use language features introduced in newer versions of Python. This PR runspyupgrade
on the code base and adds a CI test to ensure that all code uses modern language features.I'm actually hesitant to add this to CI. The developer of
pyupgrade
is the same person who develops git pre-commit hooks. This developer has a history of rude comments and dismissive remarks towards users who open issues or suggest new features. For example,pyupgrade
doesn't work unless you manually specify a list of all files you want to upgrade (hence$(find . -name "*.py")
) because the developer couldn't understand why anyone would possibly want to use this tool outside of a commit hook (asottile/pyupgrade#40). Similarly, we have to duplicate all tool flags and dependencies in.pre-commit-config.yaml
because the developer didn't understand why anyone would want to use something as silly aspyproject.toml
(pre-commit/pre-commit#1165, pre-commit/pre-commit#2056).With that aside, the tool itself is very useful. It will help greatly in modernizing our type hints for newer Python versions. So even if we don't add it to CI, we should still use it to update the repo from time to time.