-
-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Labels
Description
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 asT
. 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}")