predicates#
- starlite.utils.predicates.is_class_and_subclass(value: Any, t_type: Type[T]) TypeGuard[Type[T]] #
Return
True
ifvalue
is aclass
and 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
Generic
otherwiseFalse
.
- 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
Iterable
that 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
Optional
which is equivalent.
- A typeguard determining whether the type is
- starlite.utils.predicates.is_dataclass_class(value: Any) TypeGuard[DataclassClass] #
- Wrap
is_dataclass
in atyping.TypeGuard
, narrowing to type only, not instance.
- Parameters:
value – tested to determine if type of
dataclasses.dataclass
.- Returns:
True
ifvalue
is adataclass
type.
- Wrap
- starlite.utils.predicates.is_dataclass_class_or_instance(value: Any) TypeGuard[DataclassClassOrInstance] #
Wrap
is_dataclass
in atyping.TypeGuard
.- Parameters:
value – tested to determine if instance or type of
dataclasses.dataclass
.- Returns:
True
if 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:
True
if instance or type ofTypedDict
.