-
I can't see any incompatibility with these base classes, since they both define Is this a bug or a feature? # pyright: strict
class Protocol:
@property
def attr(self) -> object:
raise NotImplementedError
from typing import NamedTuple
class Mixin2(NamedTuple): attr: object
class Attempt2(Protocol, Mixin2): pass
# └╴E Base classes for class "Attempt2" define variable "attr" in incompatible way Pyright (reportIncompatibleVariableOverride) [12, 7] |
Beta Was this translation helpful? Give feedback.
Answered by
erictraut
Aug 6, 2024
Replies: 1 comment 6 replies
-
This is by design. You have declared the type of If you add a type declaration to |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A property is not the same as a normal attribute. In your example, the property doesn't support setting or deleting. Even if it did, the behavior would differ if you accessed the property from the class rather than a class instance. These declarations are not compatible, hence the error.