class documentation

Functions for converting abstract classes into PyTD.

Class OutputMode Controls the level of detail in pytd types. See set_output_mode.
Method __init__ Undocumented
Method annotations_to_instance_types Get instance types for annotations not present in the members map.
Method optimize_literals Optimize output of literal data structures in pyi files.
Method set_output_mode Change the level of detail in pytd types.
Method signature_to_callable Converts a function.Signature object into a callable object.
Method value_instance_to_pytd_type Get the PyTD type an instance of this object would have.
Method value_to_pytd_def Get a PyTD definition for this object.
Method value_to_pytd_type Get a PyTD type representing this object, as seen at a node.
Method _class_to_def Convert an InterpreterClass to a PyTD definition.
Method _function_call_combination_to_signature Undocumented
Method _function_call_to_return_type Get a function call's pytd return type.
Method _function_to_def Convert an InterpreterFunction to a PyTD definition.
Method _function_to_return_types Convert a function variable to a list of PyTD return types.
Method _get_values Undocumented
Method _is_instance Undocumented
Method _is_tuple Undocumented
Method _ordered_attrs_to_instance_types Get instance types for ordered attrs in the metadata.
Method _simple_func_to_def Convert a SimpleFunction to a PyTD definition.
Method _type_variable_to_def Undocumented
Method _type_variable_to_pytd_type Undocumented
Method _typed_dict_to_def Undocumented
Method _value_to_parameter_types Get PyTD types for the parameters of an instance of an abstract value.
Instance Variable _optimize_literals Undocumented
Instance Variable _output_mode Undocumented
Instance Variable _scopes Undocumented
Property _detailed Undocumented

Inherited from ContextWeakrefMixin:

Class Variable __slots__ Undocumented
Instance Variable ctx_weakref Undocumented
Property ctx Undocumented
def __init__(self, ctx): (source)
def annotations_to_instance_types(self, node, annots): (source)

Get instance types for annotations not present in the members map.

@contextlib.contextmanager
def optimize_literals(self, val=True): (source)

Optimize output of literal data structures in pyi files.

@contextlib.contextmanager
def set_output_mode(self, mode): (source)

Change the level of detail in pytd types. Args: mode: Converter.OutputMode option controlling the level of detail to use. NORMAL - the default, safe for pyi files. DETAILED - more detail, unsafe for pyi files. The converter will do things like using the names of inner classes rather than Any and including the known argument types for a callable even if the argument count is unknown. Useful for error messages. LITERAL - like DETAILED, but bool, int, str, and bytes constants will be emitted as Literal[<constant>] rather than their type. Yields: None.

def signature_to_callable(self, sig): (source)

Converts a function.Signature object into a callable object. Args: sig: The signature to convert. Returns: An abstract.CallableClass representing the signature, or an abstract.ParameterizedClass if the signature has a variable number of arguments.

def value_instance_to_pytd_type(self, node, v, instance, seen, view): (source)

Get the PyTD type an instance of this object would have. Args: node: The node. v: The object. instance: The instance. seen: Already seen instances. view: A Variable -> binding map. Returns: A PyTD type.

def value_to_pytd_def(self, node, v, name): (source)

Get a PyTD definition for this object. Args: node: The node. v: The object. name: The object name. Returns: A PyTD definition.

def value_to_pytd_type(self, node, v, seen, view): (source)

Get a PyTD type representing this object, as seen at a node. Args: node: The node from which we want to observe this object. v: The object. seen: The set of values seen before while computing the type. view: A Variable -> binding map. Returns: A PyTD type.

def _class_to_def(self, node, v, class_name): (source)

Convert an InterpreterClass to a PyTD definition.

def _function_call_combination_to_signature(self, func, call_combination, num_combinations): (source)

Undocumented

def _function_call_to_return_type(self, node, v, seen_return, num_returns): (source)

Get a function call's pytd return type.

def _function_to_def(self, node, v, function_name): (source)

Convert an InterpreterFunction to a PyTD definition.

def _function_to_return_types(self, node, fvar, allowed_type_params=()): (source)

Convert a function variable to a list of PyTD return types.

def _get_values(self, node, var, view): (source)

Undocumented

def _is_instance(self, value, cls_name): (source)

Undocumented

def _is_tuple(self, v, instance): (source)

Undocumented

def _ordered_attrs_to_instance_types(self, node, attr_metadata, annots): (source)

Get instance types for ordered attrs in the metadata.

def _simple_func_to_def(self, node, v, name): (source)

Convert a SimpleFunction to a PyTD definition.

def _type_variable_to_def(self, node, v, name): (source)

Undocumented

def _type_variable_to_pytd_type(self, node, v, seen, view): (source)

Undocumented

def _typed_dict_to_def(self, node, v, name): (source)

Undocumented

def _value_to_parameter_types(self, node, v, instance, template, seen, view): (source)

Get PyTD types for the parameters of an instance of an abstract value.

_optimize_literals = (source)

Undocumented

_output_mode = (source)

Undocumented

Undocumented

Undocumented