Skip to content

Fix type check failure stemming from new pytest release #9798

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

Merged
merged 1 commit into from
Dec 13, 2020

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Dec 13, 2020

The release of pytest 6.2 broke mypy's type checking of itself, since pytest 6.2 drops support for Python 3.5 (https://docs.pytest.org/en/stable/changelog.html#pytest-6-2-0-2020-12-12)

@gvanrossum
Copy link
Member

The subject line doesn’t really cover the fix?

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Dec 13, 2020

I didn't do a great job with the original commit message... it looks like the release of pytest 6.2 broke mypy's type checking of itself: https://travis-ci.com/github/python/mypy/jobs/458991721 and https://docs.pytest.org/en/stable/changelog.html#pytest-6-2-0-2020-12-12

@hauntsaninja hauntsaninja changed the title Fix type checking on master Fix type check failure stemming from new pytest release Dec 13, 2020
@hauntsaninja hauntsaninja merged commit 05d9fb1 into python:master Dec 13, 2020
@hauntsaninja hauntsaninja deleted the fix branch December 13, 2020 05:47
@@ -5,7 +5,8 @@ flake8-bugbear; python_version >= '3.5'
flake8-pyi>=20.5; python_version >= '3.6'
lxml>=4.4.0
psutil>=4.0
pytest>=6.1.0,<7.0.0
# pytest 6.2 does not support Python 3.5
pytest>=6.1.0,<6.2.0
Copy link
Member

Choose a reason for hiding this comment

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

Can’t you select pre-6.2 for Python 3.5 only?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, oops... My urge to get things green was all consuming and I merged right before you posted this, sorry :-(
We definitely could, although in the past we've had to make changes to mypy source code based on pytest type annotation changes, so things are a little simpler if we stick to a single pytest version for all of mypy. Hopefully we can drop Python 3.5 support soon anyway.

Copy link
Member

Choose a reason for hiding this comment

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

I worry that this declaration will stay behind even after we drop 3.5, and once we try to catch up with pytest we’d have a bunch of issues to debug all at once. But it’s fine, we can cross that bridge when we get to it.

@bluetech
Copy link
Contributor

IIUC, things broke here because the mypy self check runs on Python 3.7, which means the latest pytest gets installed (because it is compatible with Python 3.7, so pytest's python_requires >= 3.6 doesn't apply), but mypy is run with python_version = 3.5 which rejects the 3.6 syntax.

The easiest fix would be to run the CI job itself on Python 3.5, but that may not be desirable.

@hauntsaninja
Copy link
Collaborator Author

I think this is the right fix. test-requirements.txt is used by mypy devs, not just CI, and assuming most mypy devs aren't using Python 3.5 it would still make sense for it to specify a pytest that allows mypy's self type check to pass.
(Note also that we've had the opposite problem once or twice; type checking of mypy has been broken on Python 3.8 and not showed up in CI, e.g. #9693)

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