pydocstyle icon indicating copy to clipboard operation
pydocstyle copied to clipboard

Automatic inheritance of docstrings

Open mitar opened this issue 8 years ago • 3 comments

I am using custom_inherit package to automatically inherit docstrings. It would be great if pydocstyle could somehow detect that and not issue a D102 error on such methods.

I think this could be done by some simple heuristic and configuration:

  • allowing to specify a list of decorators, which if they are applied to a method make D102 not be made
  • allow to list name of a base class/metaclass used, and if it is used, D102 is not made

This might be simpler than #185 and would require only a basic check without really do dynamic analysis of the code.

mitar avatar Jul 31 '17 06:07 mitar

allowing to specify a list of decorators, which if they are applied to a method make D102 not be made

Isn't that --ignore-decorators ?

allow to list name of a base class/metaclass used, and if it is used, D102 is not made

I or Amir would have to check to see how metaclasses are represented in the AST on Py 2 and Py 3. If they're easily and statically accessible this would be a sensible addition along the lines of --ignore-decorators.

sigmavirus24 avatar Jul 31 '17 13:07 sigmavirus24

@sigmavirus24 is right about the decorator flag.

Also, (and without checking), I think it should probably be pretty easy to get both parent classes and metaclasses.

Nurdok avatar Jul 31 '17 15:07 Nurdok

I would be interested in this as well since many of my classes use DocInheritMeta as a metaclass.

I accidentally opened an issue in flake8-docstrings making this same request!

clintval avatar Dec 02 '18 20:12 clintval