[Python] Pylance is not recognizing "Methods:" section in a Python class docstring

Discussão em 'Python' iniciado por Stack, Maio 30, 2025.

  1. Stack

    Stack Membro Participativo

    Consider this Python class with docstring:

    class TestClass:
    '''
    Summary line of docstring

    Additional lines of docstring.

    Attributes:
    attr1 (int): this is the desc of a public attribute
    attr2 (bool): another desc for a second attribute

    Methods:
    calculate
    calculate()
    calculate(int)

    '''


    I used the Google style format for docstrings, with Attributes and Methods sections.

    But, in Visual Studio Code, when hovering the class name, the docstring is rendered that way: [​IMG]

    So, the Attributes section header is recognized and its elements are highlighted; but, the Methods section header isn't. Testing with a method docstring, all section headers I know (Args, Returns, Raises) are also recognized and highlighted.

    So, is there anything I can do with VSCode for Methods header to be recognized and highlighted in the docstring rendering view? maybe I'm using the wrong header?

    Continue reading...

Compartilhe esta Página