-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Update linters and python version for linting in CI #15200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add target-version = ['py37']
to this section of pyproject.toml
:
Lines 20 to 28 in b69060a
[tool.black] | |
line-length = 99 | |
target-version = ["py37", "py38", "py39", "py310", "py311"] | |
skip-magic-trailing-comma = true | |
force-exclude = ''' | |
^/mypy/typeshed| | |
^/mypyc/test-data| | |
^/test-data | |
''' |
And py_version = 37
to this section:
Lines 30 to 40 in b69060a
[tool.isort] | |
profile = "black" | |
line_length = 99 | |
combine_as_imports = true | |
skip_gitignore = true | |
extra_standard_library = ["typing_extensions"] | |
skip_glob = [ | |
"mypy/typeshed/*", | |
"mypyc/test-data/*", | |
"test-data/*", | |
] |
If we're going to start running our linters on a newer version of Python than the oldest version we support
You could use environment markers to ensure the py38+ requirements don't get installed on Python 3.7 in CI, like we do over at typeshed: https://github.com/python/typeshed/blob/853d01d55ef5b5c7f0733e62c2e214be1d472657/requirements-tests.txt#L3-L7 |
This comment has been minimized.
This comment has been minimized.
… `pyproject.toml`. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This is already added here Line 22 in b69060a
Done, thanks. I also set |
🤦♂️ Not sure how I missed that! |
Possibly we should add a sentence here to say that you'll need Python 3.8+ to install the test requirements: https://github.com/python/mypy/blob/master/CONTRIBUTING.md#4-install-the-test-requirements-and-the-project |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@@ -97,7 +97,7 @@ jobs: | |||
# but it's useful to run them with tox too, | |||
# to ensure the tox env works as expected | |||
- name: Formatting with Black + isort and code style with flake8 | |||
python: '3.7' | |||
python: '3.10' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use 3.11 here?
python: '3.10' | |
python: '3.11' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It felt slightly safer to use 3.10 😆. I still feel that 3.11 is new :P.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Diff from mypy_primer, showing the effect of this PR on open source code: pandas-stubs (https://github.com/pandas-dev/pandas-stubs) got 1.14x slower (54.3s -> 62.2s)
scikit-learn (https://github.com/scikit-learn/scikit-learn) got 1.14x faster (55.8s -> 49.0s)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Nice win on tox lint
x-ref: #15197
I updated the python version used for linting to 3.10. This gives us some time before we have to update again.
The only downside I see is if someone is using a 3.7 python environment locally and they run linters in that environment or if they installed tox with python 3.7 and they run
tox run -e lint
. A note can be added in the contributing guide to tell users what python versions are supported for dev tools. Another solution would be to delay merging this PR until python 3.7 support is dropped altogether but in this case the pre-commit-ci updates and the #15197 situation would happen again.(cc @AlexWaygood)