Skip to content

Display metadata from typing.Annotated for function parameters #2306

@SSmJaE

Description

@SSmJaE

Currently, we can use a google or other style function docstring to document parameters that we can see when using the function,
but it has these disadvantages

  1. The documentation of the parameters is not together with the parameters, sometimes it is difficult to quickly find the documentation in the docstring of the function
  2. While you can use some extensions to automatically generate docstrings, you need to sync it every time you change the parameter definition

Since after PEP 593, python now supports typing.Annotated to provide metadata, why not display the metadata by the way, but only the type of the parameter?

suppose we have this function definition

def test_func(arg: Annotated[int, "some document for this arg", ValueRange(100, 200)]):
    pass

what i want is
from
image

to
206120c7fefbfd83446378b950ddb41

I know that when I hold down the Ctrl key I can find the full definition, but if we can see the metadata (including some "documentation") just hover over the parameter, It will be better in actual use.

Related discussion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions