ezmsg.sigproc.util.typeresolution#
Functions
- check_message_type_compatibility(type1, type2)[source]#
Check if two types are compatible for message passing. Returns True if: - Both are None/NoneType - Either is typing.Any - type1 is a subclass of type2, which includes
type1 and type2 are concrete types and type1 is a subclass of type2
type1 is None/NoneType and type2 is typing.Optional, or
type1 is subtype of the non-None inner type of type2 if type2 is Optional
type1 is a Union/Optional type and all inner types are compatible with type2
- resolve_typevar(cls, target_typevar)[source]#
Resolve the concrete type bound to a TypeVar in a class hierarchy. This function traverses the method resolution order (MRO) of the class and checks the original bases of each class in the MRO for the TypeVar. If the TypeVar is found, it returns the concrete type bound to it. If the TypeVar is not found, it raises a TypeError. :param cls: The class to inspect. :type cls: type :param target_typevar: The TypeVar to resolve. :type target_typevar: typing.TypeVar
- resolve_typevar(cls, target_typevar)[source]#
Resolve the concrete type bound to a TypeVar in a class hierarchy. This function traverses the method resolution order (MRO) of the class and checks the original bases of each class in the MRO for the TypeVar. If the TypeVar is found, it returns the concrete type bound to it. If the TypeVar is not found, it raises a TypeError. :param cls: The class to inspect. :type cls: type :param target_typevar: The TypeVar to resolve. :type target_typevar: typing.TypeVar
- check_message_type_compatibility(type1, type2)[source]#
Check if two types are compatible for message passing. Returns True if: - Both are None/NoneType - Either is typing.Any - type1 is a subclass of type2, which includes
type1 and type2 are concrete types and type1 is a subclass of type2
type1 is None/NoneType and type2 is typing.Optional, or
type1 is subtype of the non-None inner type of type2 if type2 is Optional
type1 is a Union/Optional type and all inner types are compatible with type2