Enable linting rule FA102 (future-required-type-annotation) #13182
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.
This catches a common error when developing for pip, which is that you use PEP 585- or PEP 604-style type annotations because your local environment is Python 3.11+, but pip currently supports back to Python 3.8.
I have often done this myself, and it usually gets caught in CI when running the test suite, but with this rule it would get caught much earlier, either locally in pre-commit, or as part of the pre-commit CI test.
Note, that while the rule documentation suggests using
from __future__ import annotations
it is not marked as safe so Ruff will not automatically suggest it, and currently pip coding style is to simply avoid PEP 585- and PEP 604-style type annotations.This PR is waiting for #13181 to land, as I didn't want to clash with that PR.