Describe the bug
When a class inherits from a Protocol or ABC that has abstract members and is decorated by a generic instance method that is a bound method of a generic class D[T].d(cls: type[T]) -> type[T], pyright fails to detect that the resulting class is still abstract and can be instantiated. The same abstract‑instantiation check works correctly when the decorator is a generic method on a plain class E.e[T](cls: type[T]) -> type[T].
Code or Screenshots
from abc import abstractmethod
from typing import Protocol
class A(Protocol):
a: str
@abstractmethod
def test(self) -> None: ...
class D[T]:
def d(self, cls: type[T]) -> type[T]:
return cls
class E:
def e[T](self, cls: type[T]) -> type[T]:
return cls
d: D[A] = D()
e: E = E()
@d.d
class B1(A):
pass
@e.e
class B2(A):
pass
_ = B1() # pyright does NOT report an error (expected: cannot instantiate abstract class)
_ = B2() # pyright correctly reports: 'Abstract class "B2" cannot be instantiated'
VS Code extension or command-line
I'm using the pyright playground. The issue is reproducible there.
Describe the bug
When a class inherits from a
ProtocolorABCthat has abstract members and is decorated by a generic instance method that is a bound method of a generic classD[T].d(cls: type[T]) -> type[T], pyright fails to detect that the resulting class is still abstract and can be instantiated. The same abstract‑instantiation check works correctly when the decorator is a generic method on a plain classE.e[T](cls: type[T]) -> type[T].Code or Screenshots
VS Code extension or command-line
I'm using the pyright playground. The issue is reproducible there.