apache_beam.typehints.trivial_inference module¶
Trivial type inference for simple functions.
For internal use only; no backwards-compatibility guarantees.
-
exception
apache_beam.typehints.trivial_inference.TypeInferenceError[source]¶ Bases:
ValueErrorError to raise when type inference failed.
-
apache_beam.typehints.trivial_inference.instance_to_type(o)[source]¶ Given a Python object o, return the corresponding type hint.
-
class
apache_beam.typehints.trivial_inference.FrameState(f, local_vars=None, stack=())[source]¶ Bases:
objectStores the state of the frame at a particular point of execution.
-
apache_beam.typehints.trivial_inference.union(a, b)[source]¶ Returns the union of two types or Const values.
-
apache_beam.typehints.trivial_inference.finalize_hints(type_hint)[source]¶ Sets type hint for empty data structures to Any.
-
apache_beam.typehints.trivial_inference.element_type(hint)[source]¶ Returns the element type of a composite type.
-
apache_beam.typehints.trivial_inference.key_value_types(kv_type)[source]¶ Returns the key and value type of a KV type.
-
class
apache_beam.typehints.trivial_inference.BoundMethod(func, type)[source]¶ Bases:
objectUsed to create a bound method when we only know the type of the instance.
Instantiates a bound method object.
Parameters: - func (types.FunctionType) – The method’s underlying function
- type (type) – The class of the method.
-
apache_beam.typehints.trivial_inference.infer_return_type(c, input_types, debug=False, depth=5)[source]¶ Analyses a callable to deduce its return type.
Parameters: - c – A Python callable to infer the return type of.
- input_types – A sequence of inputs corresponding to the input types.
- debug – Whether to print verbose debugging information.
- depth – Maximum inspection depth during type inference.
Returns: A TypeConstraint that that the return value of this function will (likely) satisfy given the specified inputs.
-
apache_beam.typehints.trivial_inference.infer_return_type_func(f, input_types, debug=False, depth=0)[source]¶ Analyses a function to deduce its return type.
Parameters: - f – A Python function object to infer the return type of.
- input_types – A sequence of inputs corresponding to the input types.
- debug – Whether to print verbose debugging information.
- depth – Maximum inspection depth during type inference.
Returns: A TypeConstraint that that the return value of this function will (likely) satisfy given the specified inputs.
Raises: TypeInferenceError– if no type can be inferred.