class documentation

class PullInMethodClasses(visitors.Visitor): (source)

View In Hierarchy

Simplifies classes with only a __call__ function to just a method. This transforms class Foo: m: Bar class Bar: def __call__(self: Foo, ...) to class Foo: def m(self, ...) .

Method __init__ Undocumented
Method EnterTypeDeclUnit Undocumented
Method VisitClass Visit a class, and change constants to methods where possible.
Method VisitClassType Undocumented
Method VisitNamedType Undocumented
Method VisitTypeDeclUnit Undocumented
Method _CanDelete Checks whether this class can be deleted.
Method _HasSelf True if a signature has a self parameter.
Method _LookupIfSimpleCall Looks up the type if it has only one method, "__call__".
Method _MaybeLookup Undocumented
Instance Variable _module Undocumented
Instance Variable _processed_count Undocumented
Instance Variable _total_count Undocumented

Inherited from Visitor:

Method Enter Undocumented
Method Leave Undocumented
Method Visit Undocumented
Class Variable old_node Undocumented
Class Variable unchecked_node_names Undocumented
Class Variable visits_all_node_types 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): (source)
def EnterTypeDeclUnit(self, module): (source)

Undocumented

def VisitClass(self, cls): (source)

Visit a class, and change constants to methods where possible.

def VisitClassType(self, t): (source)

Undocumented

def VisitNamedType(self, t): (source)

Undocumented

def VisitTypeDeclUnit(self, unit): (source)

Undocumented

def _CanDelete(self, cls): (source)

Checks whether this class can be deleted. Returns whether all occurrences of this class as a type were due to constants we removed. Arguments: cls: A pytd.Class. Returns: True if we can delete this class.

def _HasSelf(self, sig): (source)

True if a signature has a self parameter. This only checks for the name, since the type can be too many different things (type of the method, type of the base class, object, unknown etc.) and doesn't carry over to the simplified version, anyway. Arguments: sig: Function signature (instance of pytd.Signature) Returns: True if the signature has "self".

def _LookupIfSimpleCall(self, t): (source)

Looks up the type if it has only one method, "__call__".

def _MaybeLookup(self, t): (source)

Undocumented

Undocumented

_processed_count = (source)

Undocumented

_total_count = (source)

Undocumented