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

Data Descriptors aren't properly captured #226

Closed
barbester opened this issue Feb 24, 2021 · 3 comments · Fixed by #227
Closed

Data Descriptors aren't properly captured #226

barbester opened this issue Feb 24, 2021 · 3 comments · Fixed by #227
Labels

Comments

@barbester
Copy link

Problem Description

When a class attribute is implemented as a data descriptor, pdoc doesn't seem to be able to capture its docstring correctly.

For instance, put the code below into a module called descriptor.py and run pdoc on it.

class Descriptor():
    def __init__(self, func):
        self.__doc__ = func.__doc__

    def __get__(self, instance, owner):
        return self if instance is None else getattr(instance, "_x", 0)

    def __set__(self, instance, value):
        instance._x = value


class Dummy:
    @Descriptor
    def size(self):
        """This is the size"""

The result is like this:
image

i.e. the size attribute is correctly identified as a Descriptor instance, but its __doc__ is not captured.


Now remove method __set__ from the Descriptor class, so that it is a non-data descriptor. This changes the result to:

image

i.e. now the docstring is present.

System Information

pdoc: 6.3.1
Python: 3.7.9
Platform: Windows-10-10.0.19041-SP0
@barbester barbester added the bug label Feb 24, 2021
@mhils
Copy link
Member

mhils commented Feb 24, 2021

Good catch, thanks for the detailed description! Could you please verify that #227 behaves as expected? 😃

@mhils mhils linked a pull request Feb 24, 2021 that will close this issue
@barbester
Copy link
Author

I had a look, seems fine now! Thanks for the super quick turnaround! 😃

@mhils mhils closed this as completed in 326146a Feb 25, 2021
@mhils
Copy link
Member

mhils commented Feb 25, 2021

Exellent.! 6.3.2 is out in a few minutes. 😃

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

Successfully merging a pull request may close this issue.

2 participants