summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Nothman <joel.nothman@gmail.com>2022-03-14 01:18:23 +1100
committerGitHub <noreply@github.com>2022-03-14 01:18:23 +1100
commit52ac00a50ed53f71e8d09e691dc7b2fd87c6d1e8 (patch)
tree0a34087fd1ccae4745cd05690107fa27fac430b6
parentf33a53e64f9c92bc81353a9682f796d7485a4ed7 (diff)
downloadnumpydoc-jnothman-patch-1.tar.gz
Use isgeneratorfunction to avoid overgenerating YD01jnothman-patch-1
Fixes #365 Could do with a test
-rw-r--r--numpydoc/validate.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpydoc/validate.py b/numpydoc/validate.py
index b4b7e99..d1ee978 100644
--- a/numpydoc/validate.py
+++ b/numpydoc/validate.py
@@ -179,6 +179,10 @@ class Validator:
return inspect.isfunction(self.obj)
@property
+ def is_generator_function(self):
+ return inspect.isgeneratorfunction(self.obj)
+
+ @property
def source_file_name(self):
"""
File name where the object is implemented (e.g. pandas/core/frame.py).
@@ -596,7 +600,7 @@ def validate(obj_name):
for name_or_type, type_, desc in doc.returns:
errs.extend(_check_desc(desc, "RT03", "RT04", "RT05"))
- if not doc.yields and "yield" in doc.method_source:
+ if not doc.yields and doc.is_generator_function:
errs.append(error("YD01"))
if not doc.see_also: