predicates#
- starlite.utils.predicates.is_class_and_subclass(value: Any, t_type: Type[T]) TypeGuard[Type[T]]#
Return
Trueifvalueis aclassand is a subtype oft_type.- Parameters:
value – The value to check if is class and subclass of
t_type.t_type – Type used for
issubclass()check ofvalue
- Returns:
bool
- starlite.utils.predicates.is_generic(annotation: Any) bool#
Given a type annotation determine if the annotation is a generic class.
Args: annotation: A type.
- Returns:
True if the annotation is a subclass of
GenericotherwiseFalse.
- starlite.utils.predicates.is_mapping(annotation: Any) TypeGuard[Mapping[Any, Any]]#
Given a type annotation determine if the annotation is a mapping type.
Args: annotation: A type.
- Returns:
A typeguard determining whether the type can be cast as
Mapping.
- starlite.utils.predicates.is_non_string_iterable(annotation: Any) TypeGuard[Iterable[Any]]#
Given a type annotation determine if the annotation is an iterable.
Args: annotation: A type.
- Returns:
A typeguard determining whether the type can be cast as
Iterablethat is not a string.
- starlite.utils.predicates.is_non_string_sequence(annotation: Any) TypeGuard[Sequence[Any]]#
Given a type annotation determine if the annotation is a sequence.
Args: annotation: A type.
- Returns:
class`Sequence <typing.Sequence>` that is not a string.
- Return type:
A typeguard determining whether the type can be cast as
- starlite.utils.predicates.is_any(annotation: Any) TypeGuard[Any]#
Given a type annotation determine if the annotation is Any.
Args: annotation: A type.
- Returns:
A typeguard determining whether the type is
Any.
- starlite.utils.predicates.is_union(annotation: Any) TypeGuard[Any]#
Given a type annotation determine if the annotation infers an optional union.
- Parameters:
annotation – A type.
- Returns:
A typeguard determining whether the type is
Union typing.Union>.
- starlite.utils.predicates.is_optional_union(annotation: Any) TypeGuard[Optional[Any]]#
Given a type annotation determine if the annotation infers an optional union.
- Parameters:
annotation – A type.
- Returns:
- A typeguard determining whether the type is
Union typing.Union>with a None value or
Optionalwhich is equivalent.
- A typeguard determining whether the type is
- starlite.utils.predicates.is_dataclass_class(value: Any) TypeGuard[DataclassClass]#
- Wrap
is_dataclassin atyping.TypeGuard, narrowing to type only, not instance.
- Parameters:
value – tested to determine if type of
dataclasses.dataclass.- Returns:
Trueifvalueis adataclasstype.
- Wrap
- starlite.utils.predicates.is_dataclass_class_or_instance(value: Any) TypeGuard[DataclassClassOrInstance]#
Wrap
is_dataclassin atyping.TypeGuard.- Parameters:
value – tested to determine if instance or type of
dataclasses.dataclass.- Returns:
Trueif instance or type ofdataclass.
- starlite.utils.predicates.is_typed_dict(value: Any) TypeGuard[TypedDictClass]#
Wrap
typing.is_typeddict()in atyping.TypeGuard.- Parameters:
value – tested to determine if instance or type of
typing.TypedDict.- Returns:
Trueif instance or type ofTypedDict.