Skip to content

Conversation

@hyperkai
Copy link
Contributor

@hyperkai hyperkai commented Jan 29, 2026

Fix: #20549

@github-actions

This comment has been minimized.

Updated type alias test cases to reflect syntax changes.
@github-actions

This comment has been minimized.

Update error messages for invalid syntax in type alias tests.
@github-actions

This comment has been minimized.

Add tests for type alias unpacking with lists.
@github-actions

This comment has been minimized.

Update type alias tests to reflect unpacking errors for list[int].
@github-actions

This comment has been minimized.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Not a full review, just something for you while you are fixing the tests.

unpacked = get_proper_type(item.type)
if isinstance(unpacked, Instance):
assert unpacked.type.fullname == "builtins.tuple"
if unpacked.type.fullname != "builtins.tuple":
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment above this line explaining that expand_type() may be called during semantic analysis, before invalid unpacks are fixed.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Updated test cases for TypeAlias unpacking in Python.
@github-actions

This comment has been minimized.

Removed xfail marker from test case and updated comments for clarity.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Update error messages for type alias unpacking tests.
@github-actions

This comment has been minimized.

Update error messages for unpacking list in type alias tests to reflect Python version requirements.
Updated error messages for unpacking list[int] in type alias tests.
@github-actions

This comment has been minimized.

Updated type alias test cases to reflect syntax changes in Python 3.11.
Updated test cases to reflect unpacking rules for TypeAlias.
@github-actions

This comment has been minimized.

Update comments to clarify expectations for unpacking lists in type aliases.
@github-actions

This comment has been minimized.


# Only "Test suite with py310-ubuntu, mypyc-compiled" expects: Invalid syntax
# The other tests expect: "list[int]" cannot be unpacked (must be tuple or TypeVarTuple)
# v1: TA[*list[int]]
Copy link
Member

Choose a reason for hiding this comment

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

If you want to test the new *-syntax, you should move the test to check-python311.test, then you will not need all these dances with having two separate tests, etc.

Copy link
Contributor Author

@hyperkai hyperkai Feb 1, 2026

Choose a reason for hiding this comment

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

I cannot write the tests for the code v1: TA[*list[int]] which produces 3 kinds of error through different Python versions and tests.

For v1: TA[*list[int]] :

  • Python 3.10 with only "Test suite with py310-ubuntu, mypyc-compiled" produces:

    error: Invalid syntax

  • Python 3.11 with only "Test suite with py310-ubuntu, mypyc-compiled" produces:

    error: Invalid syntax; you likely need to run mypy using Python 3.11 or newer

  • Python 3.10 and Python 3.11 with the other tests produce:

    error: "list[int]" cannot be unpacked (must be tuple or TypeVarTuple)

Copy link
Member

Choose a reason for hiding this comment

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

It is less tricky if you follow advise precisely :-)

Remove tests for unpacking type aliases in Python 3.10 and 3.11.
Removed test cases related to TypeAlias unpacking for tuples.
Remove test case for unpacked tuple with TypeAlias
Add test cases for unpacking TypeAlias with TypeVarTuple in Python 3.10 and 3.11.
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

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

@ilevkivskyi ilevkivskyi merged commit 9542fd4 into python:master Feb 1, 2026
23 checks passed
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.

Setting an unpacked list to the generic type alias gets the error message 'Please report a bug at ...'

2 participants