Skip to content

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

@hyperkai

Description

@hyperkai

*Memo:

  • mypy test.py
  • mypy 1.19.1
  • Python 3.14.0

Setting an unpacked list to the generic type alias created by a type statement gets the error message 'Please report a bug at ...' as shown below:

''' New syntax '''
type TA[*Ts] = tuple[*Ts]
''' New syntax '''

''' Old syntax '''
from typing import TypeAlias, TypeVarTuple, Unpack

Ts = TypeVarTuple('Ts')

TA: TypeAlias = tuple[*Ts]
''' Old syntax '''

v1: TA[*list[int]]        # Error
v2: TA[Unpack[list[int]]] # Error

$ mypy test.py
test.py:25: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 1.19.1
test.py:25: : note: please use --show-traceback to print a traceback when reporting a bug

$ mypy --show-traceback test.py
test.py:25: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.19.1
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "mypy\semanal.py", line 7568, in accept
File "mypy\nodes.py", line 1660, in accept
File "mypy\semanal.py", line 3329, in visit_assignment_stmt
File "mypy\semanal.py", line 3867, in process_type_annotation
File "mypy\semanal_shared.py", line 376, in has_placeholder
File "mypy\types.py", line 421, in accept
File "mypy\type_visitor.py", line 598, in visit_type_alias_type
File "mypy\types.py", line 3675, in get_proper_type
File "mypy\types.py", line 385, in _expand_once
File "mypy\types.py", line 2835, in accept
File "mypy\expandtype.py", line 468, in visit_tuple_type
AssertionError:
test.py:25: : note: use --pdb to drop into pdb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions