Skip to content

Conversation

hamdanal
Copy link
Collaborator

@hamdanal hamdanal commented May 6, 2023

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)

@hamdanal hamdanal marked this pull request as draft May 6, 2023 15:55
Copy link
Member

@AlexWaygood AlexWaygood left a 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:

mypy/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:

mypy/pyproject.toml

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

@AlexWaygood
Copy link
Member

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

@github-actions

This comment has been minimized.

@hamdanal
Copy link
Collaborator Author

hamdanal commented May 7, 2023

I think we should add target-version = ['py37'] to this section of pyproject.toml:

This is already added here

target-version = ["py37", "py38", "py39", "py310", "py311"]

And py_version = 37 to this section:

Done, thanks.

I also set skip_install = true in the tox configuration for the lint environment as installing the project itself is not needed to run any of the linters in this environment. It made the lint using tox twice as fast on my machine (33 seconds to 15 seconds, clearing the cache before the run)

@hamdanal hamdanal marked this pull request as ready for review May 7, 2023 17:38
@AlexWaygood
Copy link
Member

I think we should add target-version = ['py37'] to this section of pyproject.toml:

This is already added here

target-version = ["py37", "py38", "py39", "py310", "py311"]

🤦‍♂️ Not sure how I missed that!

@AlexWaygood
Copy link
Member

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

@github-actions

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'
Copy link
Member

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?

Suggested change
python: '3.10'
python: '3.11'

Copy link
Collaborator Author

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.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2023

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)

Copy link
Collaborator

@hauntsaninja hauntsaninja left a 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

@hauntsaninja hauntsaninja merged commit 6283516 into python:master May 7, 2023
@hamdanal hamdanal deleted the update-linters branch May 8, 2023 05:49
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.

3 participants