Skip to content
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

Filter pytype tests by stdlib/VERSIONS file #12649

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

frigus02
Copy link
Contributor

Filter the files to run pytype tests on by stdlib/VERSIONS file. This becomes important for Python 3.12, where e.g. checking asynchat.pyi requires asyncore.pyi, both of which have been removed in 3.12.

The implementation was copied from mypy_test.py and adapted to fit into the existing pytype test setup.


We're in the process of releasing a new pytype version, which will include basic support for Python 3.12. (I plan to send a separate PR for that soon.) When running pytype_test.py with that new version under 3.12 we saw errors like

stdlib/asynchat.pyi (3.12): pytype.load_pytd.BadDependencyError: Can't find pyi for 'asyncore', referenced from 'asynchat'

As far as I understand the fix is to not run on stdlib/asynchat.pyi in the first place.

Filter the files to run pytype tests on by stdlib/VERSIONS file. This
becomes important for Python 3.12, where e.g. checking asynchat.pyi
requires asyncore.pyi, both of which have been removed in 3.12.

The implementation was copied from mypy_test.py and adapted to fit into
the existing pytype test setup.
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks, this makes sense to me.

Comment on lines 165 to 170
def _supported_versions_for_module(module_versions: SupportedVersionsDict, module_name: str) -> tuple[VersionTuple, VersionTuple]:
while "." in module_name:
if module_name in module_versions:
return module_versions[module_name]
module_name = ".".join(module_name.split(".")[:-1])
return module_versions[module_name]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you instead move supported_versions_for_module from mypy_test.py to _utils.py and use the common function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Moved and imported from pytype and mypy tests.

@Avasam
Copy link
Collaborator

Avasam commented Sep 12, 2024

We're in the process of releasing a new pytype version, which will include basic support for Python 3.12. (I plan to send a separate PR for that soon.)

Good to hear! I already have an exploratory PR for Python 3.12 + Windows support using development version of pytype: #12547

I can quickly spin it into an actual PR after the next release or you can pick from it if you get to it before me.

@frigus02
Copy link
Contributor Author

@Avasam, your PR looks great. I'd probably keep the version check and just bump it. So the pytype tests now fail on Python 3.13 with a nice error message. But otherwise I think that's nice.

I can ping on your PR once we release a new version (should be in the next few days, I hope tomorrow 🤞).

@frigus02 frigus02 requested a review from srittau September 12, 2024 15:16
@srittau srittau merged commit d326c9b into python:main Sep 12, 2024
67 checks passed
@frigus02 frigus02 deleted the pytype-filter-stdlib-versions branch September 12, 2024 16:41
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