-
Notifications
You must be signed in to change notification settings - Fork 282
Closed
Closed
Copy link
Labels
Description
Describe the Bug
According to the typing spec
If the input signature in a function definition includes both a
*argsand**kwargsparameter and both are typed asAny(explicitly or implicitly because it has no annotation), a type checker should treat this as the equivalent of.... Any other parameters in the signature are unaffected and are retained as part of the signature
The example from the spec, copy-pasted into sandbox, gives 4 false positives
from typing import Any, Protocol, assert_type, Concatenate, Callable
class Proto1(Protocol):
def __call__(self, *args: Any, **kwargs: Any) -> None: ...
class Proto2(Protocol):
def __call__(self, a: int, /, *args, **kwargs) -> None: ...
class Proto3(Protocol):
def __call__(self, a: int, *args: Any, **kwargs: Any) -> None: ...
class Proto4[**P](Protocol):
def __call__(self, a: int, *args: P.args, **kwargs: P.kwargs) -> None: ...
def func(p1: Proto1, p2: Proto2, p3: Proto3) -> None:
assert_type(p1, Callable[..., None]) # Spec: ✅️ pyrefly: ❌️
assert_type(p2, Callable[Concatenate[int, ...], None]) # Spec: ✅️ pyrefly: ❌️
assert_type(p3, Callable[..., None]) # Spec: ❌️ pyrefly: ❌️
assert_type(p3, Proto4[...]) # Spec: ✅️ pyrefly: ❌️
class A:
def method(self, a: int, /, *args: Any, k: str, **kwargs: Any) -> None:
pass
class B(A):
# This override is OK because it is assignable to the parent's method.
# Spec: ✅️ pyrefly: ❌️
def method(self, a: float, /, b: int, *, k: str, m: str) -> None:
passSandbox Link
(Only applicable for extension issues) IDE Information
No response
Reactions are currently unavailable