class PullInMethodClasses(visitors.Visitor): (source)
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 |
|
Undocumented |
Method |
|
Visit a class, and change constants to methods where possible. |
Method |
|
Undocumented |
Method |
|
Undocumented |
Method |
|
Undocumented |
Method | _ |
Checks whether this class can be deleted. |
Method | _ |
True if a signature has a self parameter. |
Method | _ |
Looks up the type if it has only one method, "__call__". |
Method | _ |
Undocumented |
Instance Variable | _module |
Undocumented |
Instance Variable | _processed |
Undocumented |
Instance Variable | _total |
Undocumented |
Inherited from Visitor
:
Method |
|
Undocumented |
Method |
|
Undocumented |
Method |
|
Undocumented |
Class Variable | old |
Undocumented |
Class Variable | unchecked |
Undocumented |
Class Variable | visits |
Undocumented |
Instance Variable | enter |
Undocumented |
Instance Variable | leave |
Undocumented |
Instance Variable | visit |
Undocumented |
Instance Variable | visit |
Undocumented |
Class Variable | _visitor |
Undocumented |
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.
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".