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
The documentation states that this message is emitted when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class.
A concrete class is one where all the abstract methods have been implemented.
The problem with abstract-method is that we don't know for sure if a class is intended to be a concrete class or not. The only way we would know for sure is if it does contain all of the implemented abstract methods - but by that point the check is not useful.
The following scenario (modified from one of the examples in the documentation) is valid Python but it would emit abstract-method:
classPet:
defmake_sound(self):
raiseNotImplementedErrorclassCat(
Pet
): # W0223: Method 'make_sound' is abstract in class 'Pet' but is not overridden in child class 'Cat' (abstract-method)defjump_up(self):
print("jump!")
classTiger(Cat):
"""This is the concrete class"""defmake_sound(self):
print("rrr!")
Tiger().make_sound()
Tiger().jump_up()
The other example from the documentation emits abstract-method; however the base class does not inherit from abc.ABC, so this example emits a warning even though the class, which is not implementing the abstract method, instantiates without error:
Current problem
abstract-method documentation.
The documentation states that this message is emitted when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class.
A concrete class is one where all the abstract methods have been implemented.
The problem with
abstract-method
is that we don't know for sure if a class is intended to be a concrete class or not. The only way we would know for sure is if it does contain all of the implemented abstract methods - but by that point the check is not useful.The following scenario (modified from one of the examples in the documentation) is valid Python but it would emit
abstract-method
:The other example from the documentation emits
abstract-method
; however the base class does not inherit fromabc.ABC
, so this example emits a warning even though the class, which is not implementing the abstract method, instantiates without error:Desired solution
Deprecate and remove
abstract-method
.Additional context
#9979
#7950
#3098
Related message https://pylint.readthedocs.io/en/latest/user_guide/messages/error/abstract-class-instantiated.html
The text was updated successfully, but these errors were encountered: