module documentation

Construct and collect pytd definitions to build a TypeDeclUnit.

Class Definitions Collect definitions used to build a TypeDeclUnit.
Exception StringParseError Undocumented
Function finalize_ast Undocumented
Function pytd_annotated Create a pytd.Annotated.
Function pytd_literal Create a pytd.Literal.
Class _ContainsAnyType Check if a pytd object contains a type of any of the given names.
Class _InsertTypeParameters Visitor for inserting TypeParameter instances.
Class _PropertyToConstant Convert some properties to constant types.
Class _VerifyMutators Visitor for verifying TypeParameters used in mutations are in scope.
Function _check_module_functions Validate top-level module functions.
Function _contains_any_type Convenience wrapper for _ContainsAnyType.
Function _convert_annotated Convert everything to a string to store it in pytd.Annotated.
Function _maybe_resolve_alias Resolve the alias if possible.
Function _split_definitions Return [constants], [functions] given a mixed list of definitions.
Constant _ANNOTATED_TYPES Undocumented
Constant _CALLABLE_TYPES Undocumented
Constant _CONCATENATE_TYPES Undocumented
Constant _LITERAL_TYPES Undocumented
Constant _TUPLE_TYPES Undocumented
Constant _TYPING_SETS Undocumented
def finalize_ast(ast: pytd.TypeDeclUnit): (source)

Undocumented

def pytd_annotated(parameters: List[Any]) -> pytd.Type: (source)

Create a pytd.Annotated.

def pytd_literal(parameters: List[Any], aliases: Dict[str, pytd.Alias]) -> pytd.Type: (source)

Create a pytd.Literal.

def _check_module_functions(functions): (source)

Validate top-level module functions.

def _contains_any_type(ast, type_names): (source)

Convenience wrapper for _ContainsAnyType.

def _convert_annotated(x): (source)

Convert everything to a string to store it in pytd.Annotated.

def _maybe_resolve_alias(alias, name_to_class, name_to_constant): (source)

Resolve the alias if possible. Args: alias: A pytd.Alias name_to_class: A class map used for resolution. name_to_constant: A constant map used for resolution. Returns: None, if the alias pointed to an un-aliasable type. The resolved value, if the alias was resolved. The alias, if it was not resolved.

def _split_definitions(defs: List[Any]): (source)

Return [constants], [functions] given a mixed list of definitions.

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

Undocumented

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

Undocumented

Value
('typing.Callable', 'collections.abc.Callable')
_CONCATENATE_TYPES: tuple[str, ...] = (source)

Undocumented

Value
('typing.Concatenate', 'typing_extensions.Concatenate')
_LITERAL_TYPES: tuple[str, ...] = (source)

Undocumented

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

Undocumented

Value
('tuple', 'builtins.tuple', 'typing.Tuple')
_TYPING_SETS: tuple[str, ...] = (source)

Undocumented

Value
('typing.Intersection', 'typing.Optional', 'typing.Union')