Replies: 1 comment
-
A mix-in class should not assume anything about the classes it is combined with. Your mix-in implementation assumes that it is combined with another class that has a method called If you don't want to switch to a less-fragile pattern, you can make the above code type check by telling the type checker about your assumption. To do this, you would define a protocol class, like this: class _SupportsFancyFunction(Protocol):
def fancy_function(self):
raise NotImplementedError()
class _Minxin(_SupportsFancyFunction):
... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there! 👋 sorry. me again.
So I got along pretty nicely now with all things typing and feel much more comfortable with it by the time ..
Well: Now I look at some mixin classes for multi inheritance. And I'm kinda stumped:
This works very nicely
But OF COURSE this says
Cannot access member "fancy_function" for type "_Mixin" Member "fancy_function" is unknown
Yeah ... well. This is supposed to not be there!
How would I annotate this most conveniently 🤷♀️
Beta Was this translation helpful? Give feedback.
All reactions