Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator.method_source returns "" for property and cached_property #551

Open
anmyachev opened this issue May 7, 2024 · 1 comment
Open

Comments

@anmyachev
Copy link

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

@anmyachev
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant