diff options
author | Joel Nothman <joel.nothman@gmail.com> | 2022-03-14 01:18:23 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-14 01:18:23 +1100 |
commit | 52ac00a50ed53f71e8d09e691dc7b2fd87c6d1e8 (patch) | |
tree | 0a34087fd1ccae4745cd05690107fa27fac430b6 /numpydoc/validate.py | |
parent | f33a53e64f9c92bc81353a9682f796d7485a4ed7 (diff) | |
download | numpydoc-jnothman-patch-1.tar.gz |
Use isgeneratorfunction to avoid overgenerating YD01jnothman-patch-1
Fixes #365
Could do with a test
Diffstat (limited to 'numpydoc/validate.py')
-rw-r--r-- | numpydoc/validate.py | 6 |
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: |