ruff
ruff copied to clipboard
`D102` for "inherited" docstrings.
pydocstyle
code D102
is raised on any public methods that do not have a docstring. I agree with this in principle, except that I have many cases where I have a common base class which defines some method's interface (and documentation), but that method's specific implementation will be defined by child classes or needs to be modified by a child class. E.G.
class Parent:
def foo(self, arg1, arg2, arg3):
"""Some documentation about foo."""
# possibly in a different module or package
class Child(Parent):
def foo(self, arg1, arg2, arg3):
return arg1 + arg2 + arg3
ruff
flags foo
in Child
with D102
, when in fact this is documented by Parent.foo
.
In most cases, documenting the method in the child class would be equivalent to copy/paste of the docstring from the parent class, which I dislike. I would like the optional ability for ruff
to ignore D102
on methods defined in their parent classes.
I agree that this would be an improvement. We probably can't really support it until we start doing cross-file analysis (otherwise, it would only work if Parent
and Child
were defined in the same module, which seems like a minority of cases).
I agree that this would be an improvement. We probably can't really support it until we start doing cross-file analysis
This would be a really nice thing to have for cross-file analysis. Hopefully, you can get it to work even in cases where Parent
is defined outside the package being linted (i.e. if I am building of an interface defined by an external library). Though even getting it to work within just the package being linted would be a massive improvement
(otherwise, it would only work if
Parent
andChild
were defined in the same module, which seems like a minority of cases).
Even this would be nice, as I do have code that falls into this category (although I would still have to turn it off in general).
Would just like to mention that I would also really like to see this feature, since this is the main reason I'm not using the D
rules yet. Unfortunately I'm not proficient enough in Rust to contribute to implementing it 😅
It would be a nice start to ignore it in the same file, can that be implemented on short notice?
This issue is the only drawback I am having with ruff. Everything else is better. But this is a huge problem for me.