diff --git a/numpydoc/hooks/validate_docstrings.py b/numpydoc/hooks/validate_docstrings.py index 562a1f09..a58c1d0f 100644 --- a/numpydoc/hooks/validate_docstrings.py +++ b/numpydoc/hooks/validate_docstrings.py @@ -60,6 +60,11 @@ def name(self) -> str: def is_function_or_method(self) -> bool: return isinstance(self.node, (ast.FunctionDef, ast.AsyncFunctionDef)) + @property + def is_overload(self) -> bool: + decorators = getattr(self.node, "decorator_list", []) + return any(d.id == "overload" for d in decorators) + @property def is_generator_function(self) -> bool: if not self.is_function_or_method: diff --git a/numpydoc/validate.py b/numpydoc/validate.py index c0409c71..07e7fa78 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -277,6 +277,12 @@ def type(self): def is_function_or_method(self): return inspect.isfunction(self.obj) + @property + def is_overload(self) -> bool: + # Not sure how to figure out when a function is overloaded + # without looking at its AST + return False + @property def is_generator_function(self): return inspect.isgeneratorfunction(_unwrap(self.obj)) @@ -633,7 +639,8 @@ def validate(obj_name, validator_cls=None, **validator_kwargs): errs = [] if not doc.raw_doc: - if "GL08" not in ignore_validation_comments: + # Check if we are dealing with a `typing.overload` function + if "GL08" not in ignore_validation_comments and not doc.is_overload: errs.append(error("GL08")) return { "type": doc.type,