-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenatetopic-usability
Description
Bug Report
ParamSpec
P.args
and P.kwargs
are not defined when using explicit keyword argument.
To Reproduce
This code would be used to type anyio.run().
from typing import ParamSpec, Awaitable, TypeVar, Callable, Any
P = ParamSpec("P")
T_Retval = TypeVar("T_Retval")
def run(
func: Callable[P, Awaitable[T_Retval]],
*args: P.args,
backend: str = "asyncio",
backend_options: dict[str, Any] | None = None,
**kwargs: P.kwargs,
) -> T_Retval:
pass
but it works without explicit keyword arguments.
from typing import ParamSpec, Awaitable, TypeVar, Callable, Any
P = ParamSpec("P")
T_Retval = TypeVar("T_Retval")
def run(
func: Callable[P, Awaitable[T_Retval]],
*args: P.args,
**kwargs: P.kwargs,
) -> T_Retval:
pass
Expected Behavior
It should be able to type and recognize that run()
passes the rest of the arguments to the function a()
.
async def a(b: str, c: int) -> None:
pass
run(a, "", c=0)
Actual Behavior
main.py:10: error: Name "P.args" is not defined
main.py:13: error: Name "P.kwargs" is not defined
Your Environment
- Mypy version used: 0.981
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.10
Avasam
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenatetopic-usability