Skip to content

mypyc crashes with ParamSpec #15409

Closed
Closed
@kasium

Description

@kasium

I did my first try with mypyc but it directly crashes when I use ParamSpec

To Reproduce

from __future__ import annotations
from typing import Any, Callable, TypeVar, ParamSpec

PARAM = ParamSpec("PARAM")
RET = TypeVar("RET")

def decorator() -> Callable[[Callable[PARAM, RET]], Callable[PARAM, RET]]:
    def _wrapper(function: Callable[PARAM, RET]) -> Callable[PARAM, RET]:
        def _inner(*args: PARAM.args, **kwargs: PARAM.kwargs) -> Any:
            return function(*args, **kwargs)

        return _inner

    return _wrapper

Expected Behavior
Works

Actual Behavior

Traceback (most recent call last):
  File "mypyc/irbuild/builder.py", line 265, in accept
  File "mypy/nodes.py", line 774, in accept
  File "mypyc/irbuild/visitor.py", line 179, in visit_func_def
  File "mypyc/irbuild/function.py", line 98, in transform_func_def
  File "mypyc/irbuild/function.py", line 275, in gen_func_item
  File "mypyc/irbuild/env_class.py", line 102, in load_env_registers
  File "mypyc/irbuild/env_class.py", line 179, in add_args_to_env
  File "mypyc/irbuild/env_class.py", line 165, in num_bitmap_args
  File "mypyc/irbuild/builder.py", line 1236, in type_to_rtype
  File "mypyc/irbuild/mapper.py", line 143, in type_to_rtype
foo.py:11: AssertionError: unexpected type <class 'mypy.types.ParamSpecType'>

Your Environment

  • Mypy version used: 1.3.0
  • Mypy command-line flags: n/a
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.11.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions