class documentation

Visitor for converting ASTs back to pytd source code.

Method __init__ Undocumented
Method EnterAlias Undocumented
Method EnterClass Entering a class - record class name for children's use.
Method EnterConstant Undocumented
Method EnterLiteral Undocumented
Method EnterParameter Undocumented
Method EnterSignature Undocumented
Method EnterTypeDeclUnit Undocumented
Method LeaveClass Undocumented
Method LeaveConstant Undocumented
Method LeaveLiteral Undocumented
Method LeaveParameter Undocumented
Method LeaveSignature Undocumented
Method LeaveTypeDeclUnit Undocumented
Method MaybeCapitalize Capitalize a generic type, if necessary.
Method Print Undocumented
Method VisitAlias Convert an import or alias to a string (or None if handled elsewhere).
Method VisitAnnotated Undocumented
Method VisitAnythingType Convert an anything type to a string.
Method VisitCallableType Undocumented
Method VisitClass Visit a class, producing a multi-line, properly indented string.
Method VisitClassType Undocumented
Method VisitConcatenate Undocumented
Method VisitConstant Convert a class-level or module-level constant to a string.
Method VisitFunction Visit function, producing multi-line string (one for each signature).
Method VisitGenericType Convert a generic type to a string.
Method VisitIntersectionType Convert a intersection type ("x and y") to a string.
Method VisitLateType Undocumented
Method VisitLiteral Undocumented
Method VisitModule Undocumented
Method VisitNamedType Convert a type to a string.
Method VisitNothingType Convert the nothing type to a string.
Method VisitParameter Convert a function parameter to a string.
Method VisitParamSpec Undocumented
Method VisitParamSpecArgs Undocumented
Method VisitParamSpecKwargs Undocumented
Method VisitSignature Visit a signature, producing a string.
Method VisitStrictType Undocumented
Method VisitTemplateItem Convert a template to a string.
Method VisitTupleType Undocumented
Method VisitTypeDeclUnit Convert the AST for an entire module back to a string.
Method VisitTypeParameter Undocumented
Method VisitUnionType Convert a union type ("x or y") to a string.
Constant INDENT Undocumented
Class Variable visits_all_node_types Undocumented
Instance Variable class_names Undocumented
Instance Variable imports Undocumented
Instance Variable in_alias Undocumented
Instance Variable in_constant Undocumented
Instance Variable in_literal Undocumented
Instance Variable in_parameter Undocumented
Instance Variable in_signature Undocumented
Instance Variable multiline_args Undocumented
Instance Variable old_imports Undocumented
Method _BuildIntersection Builds a intersection of the types in type_list.
Method _BuildUnion Builds a union of the types in type_list.
Method _DropTypingConstant Undocumented
Method _FormatContainerContents Print out the last type parameter of a container. Used for *args/**kw.
Method _FormatTypeParams Undocumented
Method _FormSetTypeList Form list of types within a set type.
Method _FromTyping Undocumented
Method _GenerateImportStrings Generate import statements needed by the nodes we've visited so far.
Method _GuessModule Guess which part of the given name is the module prefix.
Method _ImportTypingExtension Undocumented
Method _IsBuiltin Undocumented
Method _IsEmptyTuple Check if it is an empty tuple.
Method _NameCollision Undocumented
Method _NeedsCallableEllipsis Check if it is typing.Callable type.
Method _NeedsTupleEllipsis Do we need to use Tuple[x, ...] instead of Tuple[x]?
Method _ProcessTypingImports Undocumented
Method _RequireImport Register that we're using name from module.
Method _StripUnitPrefix Undocumented
Method _UseExistingModuleAlias Undocumented
Constant _RESERVED Undocumented
Instance Variable _alias_imports Undocumented
Instance Variable _class_members Undocumented
Instance Variable _local_names Undocumented
Instance Variable _maybe_from_typing Undocumented
Instance Variable _module_aliases Undocumented
Instance Variable _paramspec_names Undocumented
Instance Variable _typing_import_counts Undocumented
Instance Variable _unit Undocumented

Inherited from Visitor:

Method Enter Undocumented
Method Leave Undocumented
Method Visit Undocumented
Class Variable old_node Undocumented
Class Variable unchecked_node_names Undocumented
Instance Variable enter_functions Undocumented
Instance Variable leave_functions Undocumented
Instance Variable visit_class_names Undocumented
Instance Variable visit_functions Undocumented
Class Variable _visitor_functions_cache Undocumented
def __init__(self, multiline_args=False): (source)
def EnterAlias(self, _): (source)

Undocumented

def EnterClass(self, node): (source)

Entering a class - record class name for children's use.

def EnterConstant(self, node): (source)

Undocumented

def EnterLiteral(self, _): (source)

Undocumented

def EnterParameter(self, unused_node): (source)

Undocumented

def EnterSignature(self, node): (source)

Undocumented

def EnterTypeDeclUnit(self, unit): (source)

Undocumented

def LeaveClass(self, unused_node): (source)

Undocumented

def LeaveConstant(self, node): (source)

Undocumented

def LeaveLiteral(self, _): (source)

Undocumented

def LeaveParameter(self, unused_node): (source)

Undocumented

def LeaveSignature(self, node): (source)

Undocumented

def LeaveTypeDeclUnit(self, _): (source)

Undocumented

def MaybeCapitalize(self, name): (source)

Capitalize a generic type, if necessary.

def Print(self, node): (source)

Undocumented

def VisitAlias(self, node): (source)

Convert an import or alias to a string (or None if handled elsewhere).

def VisitAnnotated(self, node): (source)

Undocumented

def VisitAnythingType(self, unused_node): (source)

Convert an anything type to a string.

def VisitCallableType(self, node): (source)

Undocumented

def VisitClass(self, node): (source)

Visit a class, producing a multi-line, properly indented string.

def VisitClassType(self, node): (source)

Undocumented

def VisitConcatenate(self, node): (source)

Undocumented

def VisitConstant(self, node): (source)

Convert a class-level or module-level constant to a string.

def VisitFunction(self, node): (source)

Visit function, producing multi-line string (one for each signature).

def VisitGenericType(self, node): (source)

Convert a generic type to a string.

def VisitIntersectionType(self, node): (source)

Convert a intersection type ("x and y") to a string.

def VisitLateType(self, node): (source)

Undocumented

def VisitLiteral(self, node): (source)

Undocumented

def VisitModule(self, node): (source)

Undocumented

def VisitNamedType(self, node): (source)

Convert a type to a string.

def VisitNothingType(self, unused_node): (source)

Convert the nothing type to a string.

def VisitParameter(self, node): (source)

Convert a function parameter to a string.

def VisitParamSpec(self, node): (source)

Undocumented

def VisitParamSpecArgs(self, node): (source)

Undocumented

def VisitParamSpecKwargs(self, node): (source)

Undocumented

def VisitSignature(self, node): (source)

Visit a signature, producing a string.

def VisitStrictType(self, node): (source)

Undocumented

def VisitTemplateItem(self, node): (source)

Convert a template to a string.

def VisitTupleType(self, node): (source)

Undocumented

def VisitTypeDeclUnit(self, node): (source)

Convert the AST for an entire module back to a string.

def VisitTypeParameter(self, node): (source)

Undocumented

def VisitUnionType(self, node): (source)

Convert a union type ("x or y") to a string.

Undocumented

Value
' '*4
class_names: list = (source)

Undocumented

Undocumented

in_alias: bool = (source)

Undocumented

in_constant: bool = (source)

Undocumented

in_literal: bool = (source)

Undocumented

in_parameter: bool = (source)

Undocumented

in_signature: bool = (source)

Undocumented

multiline_args = (source)

Undocumented

old_imports = (source)

Undocumented

def _BuildIntersection(self, type_list): (source)

Builds a intersection of the types in type_list. Args: type_list: A list of strings representing types. Returns: A string representing the intersection of the types in type_list. Simplifies Intersection[X] to X and Intersection[X, None] to Optional[X].

def _BuildUnion(self, type_list): (source)

Builds a union of the types in type_list. Args: type_list: A list of strings representing types. Returns: A string representing the union of the types in type_list. Simplifies Union[X] to X and Union[X, None] to Optional[X].

def _DropTypingConstant(self, node): (source)

Undocumented

def _FormatContainerContents(self, node: pytd.Parameter) -> str: (source)

Print out the last type parameter of a container. Used for *args/**kw.

def _FormatTypeParams(self, type_params): (source)

Undocumented

def _FormSetTypeList(self, node): (source)

Form list of types within a set type.

def _FromTyping(self, name): (source)

Undocumented

def _GenerateImportStrings(self): (source)

Generate import statements needed by the nodes we've visited so far. Returns: List of strings.

def _GuessModule(self, maybe_module): (source)

Guess which part of the given name is the module prefix.

def _ImportTypingExtension(self, name): (source)

Undocumented

def _IsBuiltin(self, module): (source)

Undocumented

def _IsEmptyTuple(self, t: pytd.GenericType) -> bool: (source)

Check if it is an empty tuple.

def _NameCollision(self, name): (source)

Undocumented

def _NeedsCallableEllipsis(self, t: pytd.GenericType) -> bool: (source)

Check if it is typing.Callable type.

def _NeedsTupleEllipsis(self, t: pytd.GenericType) -> bool: (source)

Do we need to use Tuple[x, ...] instead of Tuple[x]?

def _ProcessTypingImports(self, imports): (source)

Undocumented

def _RequireImport(self, module, name=None): (source)

Register that we're using name from module. Args: module: string identifier. name: if None, means we want 'import module'. Otherwise string identifier that we want to import.

def _StripUnitPrefix(self, name): (source)

Undocumented

def _UseExistingModuleAlias(self, name): (source)

Undocumented

_alias_imports = (source)

Undocumented

_class_members = (source)

Undocumented

_local_names: dict = (source)

Undocumented

_maybe_from_typing = (source)

Undocumented

_module_aliases: dict = (source)

Undocumented

_paramspec_names = (source)

Undocumented

_typing_import_counts = (source)

Undocumented

Undocumented