nemo_microservices._utils._typing#
Module Contents#
Functions#
Given a type like |
|
If the given type is |
|
Return whether the provided argument is an instance of |
|
API#
- nemo_microservices._utils._typing.extract_type_arg(typ: type, index: int) type#
- nemo_microservices._utils._typing.extract_type_var_from_base(
- typ: type,
- *,
- generic_bases: tuple[type, ...],
- index: int,
- failure_message: str | None = None,
Given a type like
Foo[T], returns the generic type variableT.This also handles the case where a concrete subclass is given, e.g.
class MyResponse(Foo[bytes]): ... extract_type_var(MyResponse, bases=(Foo,), index=0) -> bytes
And where a generic subclass is given:
_T = TypeVar('_T') class MyResponse(Foo[_T]): ... extract_type_var(MyResponse[bytes], bases=(Foo,), index=0) -> bytes
- nemo_microservices._utils._typing.is_annotated_type(typ: type) bool#
- nemo_microservices._utils._typing.is_iterable_type(typ: type) bool#
If the given type is
typing.Iterable[T]
- nemo_microservices._utils._typing.is_list_type(typ: type) bool#
- nemo_microservices._utils._typing.is_required_type(typ: type) bool#
- nemo_microservices._utils._typing.is_sequence_type(typ: type) bool#
- nemo_microservices._utils._typing.is_type_alias_type(
- tp: Any,
- /,
Return whether the provided argument is an instance of
TypeAliasType.type Int = int is_type_alias_type(Int) # > True Str = TypeAliasType("Str", str) is_type_alias_type(Str) # > True
- nemo_microservices._utils._typing.is_typevar(typ: type) bool#
- nemo_microservices._utils._typing.is_union_type(typ: type) bool#
- nemo_microservices._utils._typing.strip_annotated_type(typ: type) type#