Allow stubs to depend on numpy
#9499
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.
Currently, if a stubs package declares a dependency on
numpy, the latest version ofnumpywill be installed in CI when testing that package. However, the CI will then fail, because mypy will detect thatnumpyis using PEP-570 syntax, and accordingly will emit errors when run with the--python-version=3.7flag, since PEP 570 is new in Python 3.8.The solution is to actually run mypy on 3.7 in CI, rather than simply running mypy with the
--python-version=3.7flag. If we run mypy on 3.7, pip's dependency resolver will understand that the latest version ofnumpyisn't compatible with the version of Python we're using, and will give us an older version ofnumpythat's compatible with Python 3.7.A few tweaks to
tests/mypy_test.pyandtests/utils.pyare required in order to make them compatible with Python 3.7. We also can't install the whole ofrequirements-tests.txton Python 3.7, sinceflake8==6.0.0is not compatible with Python 3.7.Helps unblock #8974