[ty] Reduce false positives for ParamSpecs and TypeVarTuples (#20239)

This commit is contained in:
Alex Waygood 2025-09-04 23:34:37 +01:00 committed by GitHub
parent 08c1d3660c
commit 888a22e849
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 44 additions and 29 deletions

View file

@ -28,6 +28,23 @@ def i(callback: Callable[Concatenate[int, P], R_co], *args: P.args, **kwargs: P.
class Foo:
def method(self, x: Self):
reveal_type(x) # revealed: Self@method
def ex2(msg: str):
def wrapper(fn: Callable[P, R_co]) -> Callable[P, R_co]:
def wrapped(*args: P.args, **kwargs: P.kwargs) -> R_co:
print(msg)
return fn(*args, **kwargs)
return wrapped
return wrapper
def ex3(msg: str):
P = ParamSpec("P")
def wrapper(fn: Callable[P, R_co]) -> Callable[P, R_co]:
def wrapped(*args: P.args, **kwargs: P.kwargs) -> R_co:
print(msg)
return fn(*args, **kwargs)
return wrapped
return wrapper
```
## Type expressions