class documentation

class AnnotationPrinter(TypeStrVisitor): (source)

View In Hierarchy

Visitor used to print existing annotations in a file.

The main difference from TypeStrVisitor is a better treatment of unbound types.

Notes: * This visitor doesn't add imports necessary for annotations, this is done separately

by ImportTracker.
  • It can print all kinds of types, but the generated strings may not be valid (notably callable types) since it prints the same string that reveal_type() does.
  • For Instance types it prints the fully qualified names.
Method __init__ Undocumented
Method args​_str Convert an array of arguments to strings and join the results with commas.
Method visit​_any Undocumented
Method visit​_none​_type Undocumented
Method visit​_type​_list Undocumented
Method visit​_unbound​_type Undocumented
Instance Variable stubgen Undocumented

Inherited from TypeStrVisitor:

Method list​_str Convert items of an array to strings (pretty-print types) and join the results with commas.
Method visit​_callable​_argument Undocumented
Method visit​_callable​_type Undocumented
Method visit​_deleted​_type Undocumented
Method visit​_ellipsis​_type Undocumented
Method visit​_erased​_type Undocumented
Method visit​_instance Undocumented
Method visit​_literal​_type Undocumented
Method visit​_overloaded Undocumented
Method visit​_param​_spec Undocumented
Method visit​_partial​_type Undocumented
Method visit​_placeholder​_type Undocumented
Method visit​_raw​_expression​_type Undocumented
Method visit​_star​_type Undocumented
Method visit​_tuple​_type Undocumented
Method visit​_type​_alias​_type Undocumented
Method visit​_type​_type Undocumented
Method visit​_type​_var Undocumented
Method visit​_typeddict​_type Undocumented
Method visit​_uninhabited​_type Undocumented
Method visit​_union​_type Undocumented
Instance Variable any​_as​_dots Undocumented
Instance Variable id​_mapper Undocumented
def __init__(self, stubgen): (source)

Undocumented

Parameters
stubgen:StubGeneratorUndocumented
def args_str(self, args): (source)

Convert an array of arguments to strings and join the results with commas.

The main difference from list_str is the preservation of quotes for string arguments

Parameters
args:Iterable[Type]Undocumented
Returns
strUndocumented
def visit_any(self, t): (source)

Undocumented

Parameters
t:AnyTypeUndocumented
Returns
strUndocumented
def visit_none_type(self, t): (source)

Undocumented

Parameters
t:NoneTypeUndocumented
Returns
strUndocumented
def visit_type_list(self, t): (source)

Undocumented

Parameters
t:TypeListUndocumented
Returns
strUndocumented
def visit_unbound_type(self, t): (source)

Undocumented

Parameters
t:UnboundTypeUndocumented
Returns
strUndocumented
stubgen = (source)

Undocumented