-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
Description
Bug report
Bug description:
There is the following example in https://typing.python.org/en/latest/reference/protocols.html#defining-subprotocols-and-subclassing-protocols:
class SomeProto(Protocol):
attr: int # Note, no right hand side
# If the body is literally just "...", explicit subclasses will
# be treated as abstract classes if they don't implement the method.
def method(self) -> str: ...
class ExplicitSubclass(SomeProto):
pass
ExplicitSubclass() # error: Cannot instantiate abstract class 'ExplicitSubclass'
# with abstract attributes 'attr' and 'method'However when I run this code I do not see any error (ExplicitSubclass is initialized).
To get the desired behavior, the example would need method and attr to be explicitly marked as @abc.abstractmethod (and @property). But requiring these seems undesirable (see also #127677).
CPython versions tested on:
3.14, 3.13, 3.12
Operating systems tested on:
Linux
Reactions are currently unavailable