module documentation

Support for PEP593 (typing.Annotated) metadata. PEP593 allows metadata to be arbitrary python values. We convert these to strings to support the fact that pytd nodes are immutable, and provide converters back to python values. There are two separate forms of encoding: Internally, we want to deal with metadata as dicts with string keys, which we convert to strings to store in a pytd.Annotated node and back to dicts via `metadata.{to,from}_string`. When writing out to a pyi/pytd file, we pretty-print some types to support a more human-readable annotation, via `metadata.to_pytd`, and parse those back to dicts in pyi/parser.py. Note that only a subset of values is supported, see pyi/parser.py

Class Call Convert callables in metadata to/from generic dicts.
Function call_to_annotation Convert a function call to a metadata dict string.
Function from_string Undocumented
Function to_pytd Convert a metadata dict to a pytd string.
Function to_string Undocumented
Constant _CALLABLES Undocumented
def call_to_annotation(fn, *, posargs=None, kwargs=None): (source)

Convert a function call to a metadata dict string.

def from_string(val: str): (source)

Undocumented

def to_pytd(metadata: Dict[str, Any]): (source)

Convert a metadata dict to a pytd string.

def to_string(val: Any): (source)

Undocumented

_CALLABLES: dict[str, tuple] = (source)

Undocumented

Value
{'Deprecated': (['reason'], [])}