terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
483 stars 41 forks source link

"Keyword Args" section not recognized (DAR101 false positive) #192

Open HacKanCuBa opened 2 years ago

HacKanCuBa commented 2 years ago

Consider the following function:

def some_function(arg1: int, *, kwarg1: str) -> None:
    """Do something with the args.

    Args:
        arg1: first pos or kw argument.

    Keyword Args:
        kwarg1: first kw only argument.

    Returns:
        Nothing.
    """
    ...

darglint will raise a DAR101 Missing parameter(s) in Docstring: - kwarg1

Note that the section can be named Keyword Args or Keyword Arguments, see napoleon docs

terrencepreilly commented 2 years ago

It's not a section according to the Google styleguide. I don't think darglint's goal is to support any convention introduced by any third-party library.

Sure, it could be supported. But would it be mandatory? Under what circumstances? What about positional arguments? What configuration options? I'm not working on darglint actively, but if you want to write a well-reasoned plan for including this feature, update all of the code/tests/documentation, feel free. We could create a separate branch, and merge to the main branch once everything is copacetic.

HacKanCuBa commented 2 years ago

Alright, let me draft something.

The main idea could be that the Keyword Args section would be optional at first (not an error when present, not required to be present), and could be done mandatory in a future major version, unless we want strong adherence to the style guide, in which case it would remain optional.