Skip to content

Crash involving tuple[Unpack[tuple]] annotation #16380

@tjkuson

Description

@tjkuson

Crash Report

Ran the mypy development branch on a codebase and it crashed. I managed to reduce the crash to a function parameter typed as a nested Unpack that was passed to an f-string.

The reason I was using the development branch of mypy was that it contained a bug fix not yet in the latest release. Downgrading to 1.6.1 causes the crash to stop happening unless you pass --enable-incomplete-feature=Unpack.

The closest issue I found was #16285 which seems to be closed as completed, but I am still able to produce this crash on the latest development branch which includes the commit that closed the issue.

Traceback

/tmp/hmm.py:5: 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.6.1
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5366, in accept
  File "mypy/checkexpr.py", line 452, in visit_call_expr
  File "mypy/checkexpr.py", line 581, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1420, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1514, in check_call
  File "mypy/checkexpr.py", line 1715, in check_callable_call
  File "mypy/checkexpr.py", line 2408, in check_argument_types
AssertionError:
/tmp/hmm.py:5: : note: use --pdb to drop into pdb

To Reproduce

from typing import Unpack


def foo(*keys: Unpack[tuple[Unpack[tuple]]]):
    return f"{keys}"

Your Environment

  • Mypy version used: 1.6.1
  • Mypy command-line flags: --enable-incomplete-feature=Unpack
  • Python version used: 3.11.6
  • Operating system and version: macOS 14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions