Skip to content

Commit 9761bc2

Browse files
committed
ENH: decorator unwrapping for Yields validation.
1 parent 01b4be7 commit 9761bc2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

numpydoc/validate.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@
112112
IGNORE_COMMENT_PATTERN = re.compile("(?:.* numpydoc ignore[=|:] ?)(.+)")
113113

114114

115+
def _unwrap(obj):
116+
"""Iteratively traverse obj.__wrapped__ until first non-wrapped obj found."""
117+
while hasattr(obj, "__wrapped__"):
118+
obj = obj.__wrapped__
119+
return obj
120+
121+
115122
# This function gets called once per function/method to be validated.
116123
# We have to balance memory usage with performance here. It shouldn't be too
117124
# bad to store these `dict`s (they should be rare), but to be safe let's keep
@@ -273,7 +280,7 @@ def is_function_or_method(self):
273280

274281
@property
275282
def is_generator_function(self):
276-
return inspect.isgeneratorfunction(self.obj)
283+
return inspect.isgeneratorfunction(_unwrap(self.obj))
277284

278285
@property
279286
def source_file_name(self):

0 commit comments

Comments
 (0)