Skip to content

[Feature request] Support Annotated (Python 3.7+) #293

@diogo-rossi

Description

@diogo-rossi

The Annotated typing is a special type to add context-specific metadata to an annotation.

The doc-string generation could ignore it, as in the docs:

If a library or tool encounters an annotation Annotated[T, x] and has no special logic for the metadata, it should ignore the metadata and simply treat the annotation as T. As such, Annotated can be useful for code that wants to use annotations for purposes outside Python’s static typing system.

A direct use case for this can be, for instance, the Typer library.

Example code

import typer
from typing_extensions import Annotated


def main(name: Annotated[str, typer.Argument()]):
    print(f"Hello {name}")

Expected Result

def main(name: Annotated[str, typer.Argument()]):
    """_summary_

    _extended_summary_

    Args:
        name (str): _description_
    """
    print(f"Hello {name}")

Actual Result

def main(name: Annotated[str, typer.Argument()]):
    """_summary_

    _extended_summary_

    Args:
        name (Annotated[str, typer.Argument): _description_
    """
    print(f"Hello {name}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions