-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate
Description
Bug Report
Mypy doesn't process ParamSpec correctly.
To Reproduce
from __future__ import annotations
from collections.abc import Callable
from typing import Any, Generic, ParamSpec, TypeVar
P = ParamSpec("P")
TVFn = TypeVar("TVFn", bound=Callable[..., Any])
class Example(Generic[TVFn]):
def __init__(self, fn: TVFn):
self.fn = fn
def __call__(self: Example[Callable[P, Any]], *args: P.args, **kwargs: P.kwargs):
...
def test_fn(a: int, b: str) -> None:
...
example = Example(test_fn)
example() # mypy doesn't show an error for this call
example(1, "b") # mypy show errors for this callExpected Behavior
example() # show missing arguments here
example(1, "b") # pass hereActual Behavior
Mypy output
paramspec.py:24: error: Argument 1 to "__call__" of "Example" has incompatible type "int"; expected <nothing> [arg-type]
paramspec.py:24: error: Argument 2 to "__call__" of "Example" has incompatible type "str"; expected <nothing> [arg-type]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.1.1
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.11.2
BTW: in pyright this code working fine
maxfischer2781
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate