1

The code base I'm working has a convention on to how to document class attributes.

Here's how it looks:

@dataclass
class SessionMetadata:
    """Metadata of a Session

    Attributes:
        created_at: Date of creation, in POSIX timestamp format.
        usage_count: The number of times the session was applied to the payload.
    """

    created_at: int
    usage_count: int

However, I do not get shown my documentation when hovering over the property:

documentation not showing for the usage_count attribute

In the past, I was using another notation:

@dataclass
class SessionMetadata:
    created_at: int
    """
    Date of creation, in POSIX timestamp format.
    """

    usage_count: int
    """
    The number of times the session was applied to the payload.
    """

And I did get my documentation on hover:

documentation showing for the usage_count attribute


I tried updating Pylance. It didn't help.

I tried looking into GitHub issues, but I couldn't really find anything that mentions the format I'm using.

Has someone a similar docstring convention that shows documentation on hover, with VSCode?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • 2
    It looks like this way of commenting is not currently supported in vscode, I created a [report on GitHub](https://github.com/microsoft/vscode-python/issues/21801) that you can follow. – JialeDu Aug 11 '23 at 07:15
  • 1
    funnily, a loosely related question was asked just three days ago: https://stackoverflow.com/q/76855616/11107541 – starball Aug 11 '23 at 08:14
  • 2
    related: [What is the Python docstring format supported by Visual Studio Code?](https://stackoverflow.com/q/57017994/11107541) – starball Aug 12 '23 at 01:44

0 Answers0