Skip to content

Crash: decorator using TypeVarTuple #15667

Closed
@shaunc

Description

@shaunc

Crash Report

When checking the file below, which defines a decorator using TypeVarTuple, mypy crashes. Tested on latest "wheels".

Traceback

 % mypy src/crypto_features/features/trades/test.py --show-traceback
src/crypto_features/features/trades/test.py:10: 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.5.0+dev.2ebd51e881490f4d20635cde92ef9e3edbbad68c
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5141, in accept
  File "mypy/nodes.py", line 1903, in accept
  File "mypy/checkexpr.py", line 439, in visit_call_expr
  File "mypy/checkexpr.py", line 559, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1349, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1432, in check_call
  File "mypy/checkexpr.py", line 1623, in check_callable_call
  File "mypy/checkexpr.py", line 2286, in check_argument_types
AssertionError: 
src/crypto_features/features/trades/test.py:10: : note: use --pdb to drop into pdb

To Reproduce

File:

from typing import TypeVarTuple, TypeVar, Callable, Unpack


TT = TypeVarTuple("TT")
T = TypeVar("T")


def decorator(f: Callable[[Unpack[TT]], T]) -> Callable[[Unpack[TT]], T]:
    def wrapper(*args: Unpack[TT]) -> T:
        return f(*args)

    return wrapper


@decorator
def f(a: int, b: int) -> int:
    return a + b

Your Environment

  • Mypy version used:
    version: 1.5.0+dev.2ebd51e881490f4d20635cde92ef9e3edbbad68c
    Also tried with 1.4.1

  • Mypy command-line flags: Just " --show-traceback"

  • Mypy configuration options from mypy.ini (and other config files):

In pyproject.toml:

[tool.mypy]
allow_untyped_calls = false
enable_incomplete_feature = ["TypeVarTuple", "Unpack"]
follow_imports = "skip"
ignore_missing_imports = true
plugins = "numpy.typing.mypy_plugin"
  • Python version used: Python 3.11.3
  • Operating system and version: Macos: 13.4.1 (22F82)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions