mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-25 06:13:01 +00:00
[ty] Silence false positives for PEP-695 ParamSpec annotations (#18001)
## Summary
Suppress false positives for uses of PEP-695 `ParamSpec` in `Callable`
annotations:
```py
from typing_extensions import Callable
def f[**P](c: Callable[P, int]):
pass
```
addresses a comment here:
https://github.com/astral-sh/ty/issues/157#issuecomment-2859284721
## Test Plan
Adapted Markdown tests
This commit is contained in:
parent
235b74a310
commit
cd1d906ffa
5 changed files with 40 additions and 10 deletions
|
|
@ -249,10 +249,12 @@ Using a `ParamSpec` in a `Callable` annotation:
|
|||
```py
|
||||
from typing_extensions import Callable
|
||||
|
||||
# TODO: Not an error; remove once `ParamSpec` is supported
|
||||
# error: [invalid-type-form]
|
||||
def _[**P1](c: Callable[P1, int]):
|
||||
reveal_type(c) # revealed: (...) -> Unknown
|
||||
reveal_type(P1.args) # revealed: @Todo(ParamSpec)
|
||||
reveal_type(P1.kwargs) # revealed: @Todo(ParamSpec)
|
||||
|
||||
# TODO: Signature should be (**P1) -> int
|
||||
reveal_type(c) # revealed: (...) -> int
|
||||
```
|
||||
|
||||
And, using the legacy syntax:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue