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
fromabcimportABC, abstractmethodclassFoo(ABC):
@abstractmethoddefbar(self, arg: int=1) ->None:
""" Do something. Args: arg: Some argument. """raiseNotImplementedErrorclassDFoo(Foo):
defbar(self, arg: int=1) ->None:
print(arg) # NOTE: subclass doesn't have potential to raise a NotImplementedError
For abstractmethod, it's a common practice to make the base class's body be raise NotImplementedError. This basically denies subclasses from calling super(), double enforcing the override.
Currently, as of pydoclint==0.3.8, it throws DOC501 on the base class's docstring for a missing "raise" statement (per the NotImplementedError). However, subclasses won't have the NotImplementedError in their implementation, so this is sort of a false positive DOC501.
I think pydoclint should not be throwing DOC501 when it's a docstring for an abstractmethod in an ABC.
The text was updated successfully, but these errors were encountered:
If Foo.bar()'s body raises an exception, we need to document it in its docstring.
In this case the exception is just an artifact, since Python is a dynamic language, there is no way to enforce implementing an abstract method statically, so you need to raise an exception at runtime.
I also think that documenting the NotImplementedError is noisy and pointless. As a developer, it is enough to know that a method is abstract to know I shouldn't call it, is not like I need to handle the NotImplementedError in any way.
For
abstractmethod
, it's a common practice to make the base class's body beraise NotImplementedError
. This basically denies subclasses from callingsuper()
, double enforcing the override.Currently, as of
pydoclint==0.3.8
, it throws DOC501 on the base class's docstring for a missing "raise" statement (per theNotImplementedError
). However, subclasses won't have theNotImplementedError
in their implementation, so this is sort of a false positive DOC501.I think
pydoclint
should not be throwing DOC501 when it's a docstring for anabstractmethod
in anABC
.The text was updated successfully, but these errors were encountered: