Skip to content

Conversation

@cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Feb 1, 2024

Small change to fix an error when expanding a TypeVarTuple default.

RuntimeError: Invalid type replacement to expand: Unpack[tuple[builtins.int, builtins.str]]

Ref: #14851

@cdce8p cdce8p force-pushed the TypeVar-09-expand-TypeVarTuple branch from 7e08baf to 3f69b90 Compare February 1, 2024 21:07
@cdce8p cdce8p added the topic-pep-696 TypeVar defaults label Feb 1, 2024
Comment on lines 1542 to +1544
# WARNING: do not increase this number unless absolutely necessary,
# and you understand what you are doing.
ALLOWED_GET_PROPER_TYPES = 8
ALLOWED_GET_PROPER_TYPES = 9
Copy link
Collaborator Author

@cdce8p cdce8p Feb 1, 2024

Choose a reason for hiding this comment

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

@JelleZijlstra The test here just counts all get_proper_type calls inside expandtype. I believe the change still makes sense and is necessary to be able to compare the type inside Unpack. Furthermore, it's guarded by the isinstance check so the performance penalty should probably be minimal. Let me know what you think.

No other test case so far would reach that, only the new TypeVarTuple default ones.

@cdce8p cdce8p requested a review from JelleZijlstra February 1, 2024 21:19
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2024

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@JelleZijlstra JelleZijlstra merged commit 3804f7e into python:master Feb 3, 2024
@cdce8p cdce8p deleted the TypeVar-09-expand-TypeVarTuple branch February 3, 2024 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-pep-696 TypeVar defaults

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants