Utilities for pytd. This provides a utility function to access data files in a way that works either locally or within a larger repository.
Class |
|
A simple ordered set. |
Class |
|
Utility class for building union types. |
Class |
|
Base class for modules that match types against each other. |
Function |
|
Undocumented |
Function |
|
Undocumented |
Function |
|
Convert a PYTD node to a canonical (sorted) ordering. |
Function |
|
Concatenate two or more pytd ASTs. |
Function |
|
Undocumented |
Function |
|
Diff two lists of (name, pickled_module). |
Function | disabled |
Disable a function. |
Function |
|
Create a simple method using only "Any"s as types. |
Function |
|
Compute a class->subclasses mapping. |
Function |
|
Undocumented |
Function |
|
Combine a list of types into a union type, if needed. |
Function |
|
If we have type params, build a generic type, a normal type otherwise. |
Function |
|
Returns a type annotation and any added imports. |
Function |
|
Whether t.name matches full_name in format {module}.{member}. |
Function |
|
Merge a base class into a subclass. |
Function |
|
Create Classtype / NamedType. |
Function |
|
Create NamedType, dotted if we have a module. |
Function |
|
Undocumented |
Function |
|
Undocumented |
Function |
|
Return the type list for union type, or a list with the type itself. |
Function |
|
Given a list (classes, functions, etc.), wrap a pytd around them. |
Constant | ANON |
Undocumented |
Function | _check |
Check for duplicate identifiers. |
Constant | _TUPLE |
Undocumented |
Disable a function. Disable a previously defined function foo as follows: foo = disabled_function Any later calls to foo will raise an AssertionError. This is used, e.g., in cfg.Program to prevent the addition of more nodes after we have begun solving the graph. Raises: AssertionError: If something tried to call the disabled function.
Create a simple method using only "Any"s as types. Arguments: name: The name of the method *params: The parameter names. Returns: A pytd.Function.
Compute a class->subclasses mapping. Args: ast: Parsed PYTD. Returns: A dictionary, mapping instances of pytd.Type (types) to lists of pytd.Class (the derived classes).
Combine a list of types into a union type, if needed. Leaves singular return values alone, or wraps a UnionType around them if there are multiple ones, or if there are no elements in the list (or only NothingType) return NothingType. Arguments: types: A list of types. This list might contain other UnionTypes. If so, they are flattened. Returns: A type that represents the union of the types passed in. Order is preserved.
Merge a base class into a subclass. Arguments: cls: The subclass to merge values into. pytd.Class. base: The superclass whose values will be merged. pytd.Class. Returns: a pytd.Class of the two merged classes.
Given a list (classes, functions, etc.), wrap a pytd around them. Args: name: The name attribute of the resulting TypeDeclUnit. items: A list of items. Can contain pytd.Class, pytd.Function and pytd.Constant. Returns: A pytd.TypeDeclUnit. Raises: ValueError: In case of an invalid item in the list. NameError: For name conflicts.