Skip to content

Support custom descriptors as attributes #820

@gpollo

Description

@gpollo

Problem Description

Python descriptor don't seem to be typed properly.

Steps to reproduce the behavior:

class MyDescriptor:
    def __get__(self, obj, objtype = None) -> bool:
        return False

class Test:
    @property
    def hello(self) -> int:
        """hello world"""
        return 10
    
    foo = MyDescriptor()
    """foo bar"""

The @property is properly generated in the doc as hello: int. My understanding is that @property are basically Python descriptors.

My custom descriptor is generated as def foo(unknown):. I'm not sure how other tools handle this use case, I'd have to check. I would be expecting def foo(self) -> bool: or foo: bool.

Image

System Information

pdoc: 14.7.0
Python: 3.10.4
Platform: Windows-10-10.0.22631-SP0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions