[ty] Remove false positives when subscripting Generic or Protocol with a ParamSpec or TypeVarTuple (#19749)

This commit is contained in:
Alex Waygood 2025-08-04 21:42:46 +01:00 committed by GitHub
parent 739c94f95a
commit 3a9341f7be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 14 deletions

View file

@ -1052,8 +1052,7 @@ class FooLegacy(Generic[T]):
class Bar[T, **P]:
def __call__(self): ...
# TODO: should not error
class BarLegacy(Generic[T, P]): # error: [invalid-argument-type] "`ParamSpec` is not a valid argument to `Generic`"
class BarLegacy(Generic[T, P]):
def __call__(self): ...
static_assert(is_assignable_to(Foo, Callable[..., Any]))
@ -1064,9 +1063,7 @@ static_assert(is_assignable_to(BarLegacy, Callable[..., Any]))
class Spam[T]: ...
class SpamLegacy(Generic[T]): ...
class Eggs[T, **P]: ...
# TODO: should not error
class EggsLegacy(Generic[T, P]): ... # error: [invalid-argument-type] "`ParamSpec` is not a valid argument to `Generic`"
class EggsLegacy(Generic[T, P]): ...
static_assert(not is_assignable_to(Spam, Callable[..., Any]))
static_assert(not is_assignable_to(SpamLegacy, Callable[..., Any]))