You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a usecase where I have a few interfaces which are classes that each inherit from abc.ABC. Each interface defines a set of abstract methods to implement in order to satisfy said interface. I then have several hundred classes that inherit from one of these interfaces. I like this because the interfaces give a clear view of the API. I would really like it if the type hints that I define in my interfaces apply to the classes that inherit from them.
Basically, I would like mypy to raise an error for the following script:
importabcclassFoo(abc.ABC):
@abc.abstractmethoddefspeak(self, msg: str) ->None:
passclassBar(Foo):
defspeak(self, msg):
print(msg)
b=Bar()
b.speak(1) # not a str!
I'm aware that I can copy/paste the type hint from Foo.speak into Bar.speak, but I find that inelegant, error-prone, and less efficient from a code maintenance perspective.
Sorry if this is a duplicate; I tried to search for a similar issue but didn't find one. Feel free to point me to a relevant issue and to close this issue if so.
The text was updated successfully, but these errors were encountered:
I have a usecase where I have a few interfaces which are classes that each inherit from
abc.ABC
. Each interface defines a set of abstract methods to implement in order to satisfy said interface. I then have several hundred classes that inherit from one of these interfaces. I like this because the interfaces give a clear view of the API. I would really like it if the type hints that I define in my interfaces apply to the classes that inherit from them.Basically, I would like
mypy
to raise an error for the following script:I'm aware that I can copy/paste the type hint from
Foo.speak
intoBar.speak
, but I find that inelegant, error-prone, and less efficient from a code maintenance perspective.Sorry if this is a duplicate; I tried to search for a similar issue but didn't find one. Feel free to point me to a relevant issue and to close this issue if so.
The text was updated successfully, but these errors were encountered: