Skip to content

Fix type analysis for typing.Unpack #15228

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 3 commits into from
May 17, 2023
Merged

Conversation

jhance
Copy link
Collaborator

@jhance jhance commented May 12, 2023

We were checking only for typing_extensions.Unpack, which breaks code when checking at 3.11+ even if importing typing_extensions because its just a re-export from typing.

These basic pythoneval tests also assert that the feature at least somewhat works with the real stubs - otherwise up until now we had basically no coverage of that, and were relying on the fake typing stubs to be close enough to the real thing.

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

This comment has been minimized.


[case testTypeVarTuple]
# flags: --enable-incomplete-feature=TypeVarTuple --enable-incomplete-feature=Unpack --python-version=3.11
from typing import Any, Callable, Unpack, TypeVarTuple
Copy link
Member

Choose a reason for hiding this comment

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

CI fails if this is run before 3.11 (because Unpack doesn't exist). Not sure what the incantation is to make this test run only on 3.11+.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that adding if sys.version_info >= (3, 11) around the entire test case should do the trick.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

spack (https://github.com/spack/spack) got 1.08x faster (80.9s -> 74.7s)

@JukkaL JukkaL merged commit 905c2cb into python:master May 17, 2023
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.

4 participants