SublimeAutoDocstring icon indicating copy to clipboard operation
SublimeAutoDocstring copied to clipboard

Type annotated class attributes aren't extracted

Open Odyseus opened this issue 3 years ago • 0 comments

Hello, everybody.

Given the following class...

class ClassName():

    """Summary

    Attributes
    ----------
    attr1 : TYPE
        Description
    attr3 : TYPE
        Description
    """

    attr1 = None
    attr2: str = None

    def __init__(self):
        """Summary
        """
        self.attr3 = None
        self.attr4: str = None

    def do_something(self, arg1: str, arg2, kwarg1: str = None, kwarg2=None):
        """Summary

        Parameters
        ----------
        arg1 : str
            Description
        arg2 : TYPE
            Description
        kwarg1 : str, optional
            Description
        kwarg2 : None, optional
            Description
        """
        pass

...it can be seen that all of the class' attributes that are type annotated (attr2 and attr4) aren't extracted by AutoDocstring. Non-annotated class attributes and all the arguments of the do_something method, whether they are annotated or not, are extracted fine.

Note: The mixed annotated and non-annotated fields depicted in the example are for demonstration purposes. I normally use non-annotated code, but I started using type annotated code in one Python module because it is required by a module that I use (dataclasses).

Odyseus avatar Feb 22 '22 19:02 Odyseus