Skip to content

Crash on unpacked tuple in tuple type definition #21933

Description

@dzsaska

Crash Report
Mypy 1.20.2 is crashing when processing type definition of a tuple that unpacks another tuple. I have a reproducer on mypy-play with latest version (2.3.1). See https://mypy-play.net/?gist=43e256f314819d34c14f92b9098ed40c

Traceback

mre.py:12: 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.20.2
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "mypy/checkexpr.py", line 6092, in accept
  File "mypy/checkexpr.py", line 6127, in accept_maybe_cache
  File "mypy/nodes.py", line 2469, in accept
  File "mypy/checkexpr.py", line 502, in visit_call_expr
  File "mypy/checkexpr.py", line 639, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1489, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1593, in check_call
  File "mypy/checkexpr.py", line 2749, in check_overload_call
  File "mypy/checkexpr.py", line 2917, in infer_overload_return_type
  File "mypy/checkexpr.py", line 1582, in check_call
  File "mypy/checkexpr.py", line 1747, in check_callable_call
  File "mypy/checkexpr.py", line 2060, in infer_function_type_arguments_using_context
  File "mypy/checkexpr.py", line 3292, in apply_generic_arguments
  File "mypy/applytype.py", line 115, in apply_generic_arguments
  File "mypy/applytype.py", line 79, in get_target_type
  File "mypy/subtypes.py", line 189, in is_subtype
  File "mypy/subtypes.py", line 363, in _is_subtype
  File "mypy/types.py", line 2818, in accept
  File "mypy/subtypes.py", line 798, in visit_tuple_type
  File "mypy/typeops.py", line 119, in tuple_fallback
NotImplementedError: 
mre.py:12: note: use --pdb to drop into pdb

To Reproduce
See https://mypy-play.net/?gist=43e256f314819d34c14f92b9098ed40c

"""
Minimal reproducer: mypy 1.20.2 (and latest 2.3.1) crashes on a nested tuple type alias unpack.
"""

from collections import deque

type Inner = tuple[int, str]
type Outer = tuple[bool, *Inner]


class K(Base):
    q: deque[Outer] = deque()


class Base: ...

Your Environment

  • Mypy version used: 1.20.2 and 2.3.1
  • Mypy command-line flags: python -m mypy --python-version 3.12 --no-incremental --cache-dir=/dev/null --show-traceback mre.py
  • Python version used: Python 3.12.13

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions