Python-language-server: How to write Doc String for Enums ?

Created on 29 Oct 2019  路  5Comments  路  Source: microsoft/python-language-server

I want to get the Doc String for every single Enum Item like Timing.Setup.LoginDialog if I hover them ( in this case I want to hover LoginDialog and see 30 Seconds - Maximum Time.. ) in VSCode.

Here the Example Code:

from enum import Enum


class Timing:

    class Setup(Enum):
        Open = 300  # 5 Minutes - Maximum Time the Setup Application needs to open
        LoginDialog = 30  # 30 Seconds - Maximum Time the Fadein of the Login Dialog needs
enhancement signatures tooltips

Most helpful comment

Docs written is comments, is not supported in many places like mkdocstrings.

I propose that the docstring should be written in a normal fashion, here is an example.

class APIErrorCode(str, Enum):
    """Enumerate API error codes."""

    Unauthorized = "unauthorized"
    """The bearer token is not valid."""

    RestrictedResource = "restricted_resource"
    """Given the bearer token used, the client doesn't have permission to
    perform this operation."""

    ObjectNotFound = "object_not_found"
    """Given the bearer token used, the resource does not exist.
    This error can also indicate that the resource has not been shared with owner
    of the bearer token."""

All 5 comments

@dschiller This looks like a feature request on language server. Moving to the LS repo.

Is there some specification as to how enum member comments are supposed to work? It's possible to show this sort of documentation on enum members, but we'd have to know the "right" way to do it.

i, too am hoping for this feature to be implemented. (not useful, just bumping because pep8)

Docs written is comments, is not supported in many places like mkdocstrings.

I propose that the docstring should be written in a normal fashion, here is an example.

class APIErrorCode(str, Enum):
    """Enumerate API error codes."""

    Unauthorized = "unauthorized"
    """The bearer token is not valid."""

    RestrictedResource = "restricted_resource"
    """Given the bearer token used, the client doesn't have permission to
    perform this operation."""

    ObjectNotFound = "object_not_found"
    """Given the bearer token used, the resource does not exist.
    This error can also indicate that the resource has not been shared with owner
    of the bearer token."""
Was this page helpful?
0 / 5 - 0 ratings