This repository was archived by the owner on Nov 3, 2023. It is now read-only.
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
Wrong “D103: Missing docstring in public function” for overload functions #419
Closed
Description
For example:
from typing import overload
@overload
def func(a: int) -> str:
...
@overload
def func(a: str) -> str:
...
def func(a):
"""Foo bar documentation."""
return str(a)
will result in
/home/raabf/Dokumente/overload_test.py:4 in public function `func`:
D103: Missing docstring in public function
/home/raabf/Dokumente/overload_test.py:7 in public function `func`:
D103: Missing docstring in public function
Which is wrong since only the last def should have a docstring.
Two things should be done:
First, prevent the error D103 for overload functions. We could make use of the --ignore-decorators='overload'
, but since it is universally valid, it should be a fixed part of it, and the user should not set it by himself.
Second, since @overload
functions should never have docstrings, it would be useful if there is an additional error code in pydocstyle, if someone is setting a docstring for an @overload
function.