poprox_recommender.lkpipeline.types#
Functions
|
Make a best-effort check whether a type is compatible with at least one target type. |
|
Make a best-effort check whether a type is compatible with at least one target type. |
|
Compute a string representation of a type that is both resolvable and human-readable. |
|
Compute a string representation of a type that is both resolvable and human-readable. |
Classes
|
Type for accepting lazy inputs from the pipeline runner. |
Exceptions
Warnings about type-checking logic. |
- exception poprox_recommender.lkpipeline.types.TypecheckWarning#
Bases:
UserWarning
Warnings about type-checking logic.
- class poprox_recommender.lkpipeline.types.Lazy(*args, **kwargs)#
-
Type for accepting lazy inputs from the pipeline runner. If your function may or may not need one of its inputs, declare the type with this to only run it as needed:
def my_component(input: str, backup: Lazy[str]) -> str: if input == 'invalid': return backup.get() else: return input
- get()#
Get the value behind this lazy instance.
- Return type:
T
- poprox_recommender.lkpipeline.types.is_compatible_type(typ, *targets)#
Make a best-effort check whether a type is compatible with at least one target type. This function is limited by limitations of the Python type system and the effort required to (re-)write a full type checker. It is written to be over-accepting instead of over-restrictive, so it can be used to reject clearly incompatible types without rejecting combinations it cannot properly check.
- poprox_recommender.lkpipeline.types.is_compatible_data(obj, *targets)#
Make a best-effort check whether a type is compatible with at least one target type. This function is limited by limitations of the Python type system and the effort required to (re-)write a full type checker. It is written to be over-accepting instead of over-restrictive, so it can be used to reject clearly incompatible types without rejecting combinations it cannot properly check.
- poprox_recommender.lkpipeline.types.type_string(typ)#
Compute a string representation of a type that is both resolvable and human-readable. Type parameterizations are lost.