KEMBAR78
Mypy crash when unpacking typevar tuples (not TypeVarTuple) · Issue #17755 · python/mypy · GitHub
Skip to content

Mypy crash when unpacking typevar tuples (not TypeVarTuple) #17755

@kdkavanagh

Description

@kdkavanagh

Crash Report

Unpacked *args tuple type with TypeVar crashes mypy. Offending source below, crash occurred after introducing *tuple[_S1] as the *args type. This overload is necessary instead of a TypeVarTuple due to the challenge described here

_S1 = TypeVar("_S1", bound=_ScopeType)

@overload
def create_scoped(
    arg1: Arg1,
    arg2: Union[type[TraitsLikeT], TraitsLikeT],
    *scopes: * tuple[_S1 | type[_S1] ],
) -> ScopeContainer[TraitsLikeT, _S1]: ...

Traceback

src/mylib/api/scope.py:238: 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.11.2
Traceback (most recent call last):
  File "mypy/checker.py", line 591, in accept
  File "mypy/nodes.py", line 589, in accept
  File "mypy/checker.py", line 628, in visit_overloaded_func_def
  File "mypy/checker.py", line 658, in _visit_overloaded_func_def
  File "mypy/checker.py", line 825, in check_overlapping_overloads
  File "mypy/subtypes.py", line 1855, in unify_generic_callable
  File "mypy/constraints.py", line 317, in infer_constraints
  File "mypy/constraints.py", line 410, in _infer_constraints
  File "mypy/types.py", line 2004, in accept
  File "mypy/constraints.py", line 1085, in visit_callable_type
  File "mypy/constraints.py", line 1440, in repack_callable_args
AssertionError:

Your Environment

  • Mypy version used: mypy 1.11.2 (compiled: yes)
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files): Only set python_version = 3.11
  • Python version used: Python 3.11.9
  • Operating system and version: rhel8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions