module documentation

Parse a pyi file using typed_ast.

Class AnnotationVisitor Converts typed_ast annotations to pytd.
Class MetadataVisitor Converts typing.Annotated metadata.
Class PyiOptions Pyi parsing options.
Class Splice Splice a list into a node body.
Function canonical_pyi Rewrite a pyi in canonical form.
Function parse_pyi Parse a pyi string.
Function parse_pyi_debug Debug version of parse_pyi.
Function parse_string Undocumented
Function post_process_ast Post-process the parsed AST.
Class _GeneratePytdVisitor Converts a typed_ast tree to a pytd tree.
Class _ParamSpec Internal representation of ParamSpec.
Class _TypeVar Internal representation of TypeVar.
Class _TypeVariable Internal representation of type variables.
Function _attribute_to_name Recursively convert Attributes to Names.
Function _feature_version Get the python feature version for the parser.
Function _flatten_splices Flatten a list with nested Splices.
Function _import_from_module Convert a typedast import's 'from' into one that add_import expects.
Function _parse Call the typed_ast parser with the appropriate feature version.
Function _tuple_of_import Convert a typedast import into one that add_import expects.
Constant _ANNOTATED_IDS Undocumented
Constant _COLL_NAMEDTUPLE_IDS Undocumented
Constant _FINAL_IDS Undocumented
Constant _NEWTYPE_IDS Undocumented
Constant _PARAMSPEC_IDS Undocumented
Constant _TOPLEVEL_PYI_OPTIONS Undocumented
Constant _TYPE_ALIAS_IDS Undocumented
Constant _TYPEDDICT_IDS Undocumented
Constant _TYPEVAR_IDS Undocumented
Constant _TYPING_LITERAL_IDS Undocumented
Constant _TYPING_NAMEDTUPLE_IDS Undocumented
def canonical_pyi(pyi, multiline_args=False, options=None): (source)

Rewrite a pyi in canonical form.

def parse_pyi(src: str, filename: Optional[str], module_name: str, options: Optional[PyiOptions] = None) -> pytd.TypeDeclUnit: (source)

Parse a pyi string.

def parse_pyi_debug(src: str, filename: str, module_name: str, options: Optional[PyiOptions] = None) -> Tuple[pytd.TypeDeclUnit, _GeneratePytdVisitor]: (source)

Debug version of parse_pyi.

def parse_string(src: str, name: Optional[str] = None, filename: Optional[str] = None, options: Optional[PyiOptions] = None): (source)

Undocumented

def post_process_ast(ast, src, name=None): (source)

Post-process the parsed AST.

def _attribute_to_name(node: ast3.Attribute) -> ast3.Name: (source)

Recursively convert Attributes to Names.

def _feature_version(python_version: Tuple[int, ...]) -> int: (source)

Get the python feature version for the parser.

def _flatten_splices(body: List[Any]) -> List[Any]: (source)

Flatten a list with nested Splices.

def _import_from_module(module: Optional[str], level: int) -> str: (source)

Convert a typedast import's 'from' into one that add_import expects.

def _parse(src: str, feature_version: int, filename: str = ''): (source)

Call the typed_ast parser with the appropriate feature version.

def _tuple_of_import(alias: ast3.alias) -> Union[str, Tuple[str, str]]: (source)

Convert a typedast import into one that add_import expects.

_ANNOTATED_IDS: tuple[str, ...] = (source)

Undocumented

Value
('Annotated', 'typing.Annotated', 'typing_extensions.Annotated')
_COLL_NAMEDTUPLE_IDS: tuple[str, ...] = (source)

Undocumented

Value
('namedtuple', 'collections.namedtuple')
_FINAL_IDS: tuple[str, ...] = (source)

Undocumented

Value
('typing.Final', 'typing_extensions.Final')
_NEWTYPE_IDS: tuple[str, ...] = (source)

Undocumented

Value
('NewType', 'typing.NewType')
_PARAMSPEC_IDS: tuple[str, ...] = (source)

Undocumented

Value
('ParamSpec', 'typing.ParamSpec', 'typing_extensions.ParamSpec')
_TOPLEVEL_PYI_OPTIONS: tuple[str, ...] = (source)

Undocumented

Value
('platform', 'python_version', 'strict_primitive_comparisons')
_TYPE_ALIAS_IDS: tuple[str, ...] = (source)

Undocumented

Value
('typing.TypeAlias', 'typing_extensions.TypeAlias')
_TYPEDDICT_IDS: tuple[str, ...] = (source)

Undocumented

Value
('TypedDict', 'typing.TypedDict', 'typing_extensions.TypedDict')
_TYPEVAR_IDS: tuple[str, ...] = (source)

Undocumented

Value
('TypeVar', 'typing.TypeVar')
_TYPING_LITERAL_IDS: tuple[str, ...] = (source)

Undocumented

Value
('Literal', 'typing.Literal', 'typing_extensions.Literal')
_TYPING_NAMEDTUPLE_IDS: tuple[str, ...] = (source)

Undocumented

Value
('NamedTuple', 'typing.NamedTuple')