numpy / numpydoc

Numpy's Sphinx extensions

Home Page:https://numpydoc.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Validator.method_source` returns `""` for `property` and `cached_property`

anmyachev opened this issue · comments

An interesting detail is that source_file_def_line method takes into account these types of objects and correctly finds the source code of the functions wrapped in these properties.

def source_file_def_line(self):
"""
Number of line where the object is defined in its file.
"""
try:
if isinstance(self.code_obj, property):
sourcelines = self._getsourcelines(self.code_obj.fget)
elif isinstance(self.code_obj, functools.cached_property):
sourcelines = self._getsourcelines(self.code_obj.func)
else:
sourcelines = self._getsourcelines(self.code_obj)
# getsourcelines will return the line of the first decorator found for the

Validator.name also doesn't work for functools.cached_property.