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
Suppose I have a mixin class "FooMixin" for a class "Bar" and inside the mixin are used base attributes / methods from the "Bar" class.
Mypy returns AttributeError:
mixins/file.py:line_number: error: "FooMixin" has no attribute "blabla"
I would except from mypy to browse a project directory to find a class, where is the "FooMixin" inherited and check, if the attributes and methods are defined here. If not, print the error above.
The text was updated successfully, but these errors were encountered:
That's a reasonable expectation, but it's not how mypy works at the moment. Mypy doesn't check all the places a mixin is used. Instead, it requires classes to be valid by themselves. Our recommended approach to mixins is to define an ABC that declares the API they can use, and to have both the mixin and classes that use the mixin inherit from the ABC.
Suppose I have a mixin class "FooMixin" for a class "Bar" and inside the mixin are used base attributes / methods from the "Bar" class.
Mypy returns
AttributeError
:I would except from mypy to browse a project directory to find a class, where is the "FooMixin" inherited and check, if the attributes and methods are defined here. If not, print the error above.
The text was updated successfully, but these errors were encountered: