Remove linters from requirements-tests.txt #12725
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.
These days, we do all our linting in CI via pre-commit; linters are only listed in
requirements-tests.txt
for local convenience, as pre-commit uses an isolated virtual environment for each linting tool it executes. But runningpre-commit run -a black
isn't really much more to type thanblack
, and installing all these linters into the same environment is starting to cause issues. (See: the CI failures in #12717.) Flake8-pyi has dropped support for Python 3.8 in its latest version, and other linters are likely to soon follow, but per the consensus in #12716 we probably won't do so until the new year. If we're happy to do our linting via pre-commit locally as well as doing it via pre-commit in CI, that makes the situation caused by some tools dropping support for Python 3.8 quite a lot less problematic.The only linter that I think we do need to keep in
requirements-tests.txt
is Ruff, because we run it as a subprocess fromcreate_baseline_stubs.py
, and we run it in that script with slightly different arguments to the ones we use in our pre-commit config file.If we don't want to go this route, then we can just use environment markers in the
requirements-tests.txt
file to specify that the linting dependencies only need to be installed on Python 3.9+. We did this for a while after flake8 and flake8-pyi dropped support for Python 3.7 (until 487e331), and it worked fine. The main disadvantages of that approach are (1) that it feels like a bit of a hack, and (2) we'll probably run into the same issue again when Python 3.9 goes EOL in around a year's time. This approach solves it for the long term.