fqr.core.typ.utl.check module

Type checking utility functions.

get_args(tp: Any) tuple[Any, ...]

Wrapper for lib.t.get_args.

get_checkable_types(any_tp: type[typ.AnyType] | type[lib.t.Any] | lib.t.Any) tuple[typ.AnyType | type, ...] | tuple[type, ...]

Get checkable origin lib.types, handling Union and TypeVar expansions automatically.

Literals will be returned as their values.

Annotated, ClassVar, Final, and InitVar are expanded as their parameter arguments.

expand_types(any_tp: type[typ.AnyType] | lib.t.Any) tuple[type[typ.AnyType] | type[lib.t.Any], ...] | tuple[type[Any], ...]

Recursively get valid subtypes into flattened tuple from a passed type, Union, or TypeVar.

Literals will be returned as their values.

Annotated, ClassVar, Final, and InitVar are expanded as their parameter arguments.

is_array(obj: typ.Array[typ.AnyType | lib.t.Any] | lib.t.Any) lib.t.TypeGuard[typ.Array[typ.AnyType | lib.t.Any]]

Return True if obj is Array[lib.t.Any].

is_array_type(tp: type[typ.ArrayType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.ArrayType]]

Return True if tp is type[Array[lib.t.Any]].

is_bool_type(tp: type[typ.AnyType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[bool] | type[typ.AnyType]]

Return True if tp is type[bool].

is_date_type(tp: type[Any] | Any) TypeGuard[type[date]]

Return True if tp is datetime.date.

is_datetime_type(tp: type[Any] | Any) TypeGuard[type[datetime]]

Return True if tp is datetime.datetime.

is_field(obj_: typ.AnyField[typ.AnyType] | lib.t.Any) TypeGuard[typ.AnyField[typ.AnyType] | typ.AnyField[lib.t.Any]]

Return True if obj_ typ AnyField[Any]`.

is_field_type(tp: type[typ.AnyField[typ.AnyType]] | lib.t.Any) TypeGuard[type[typ.AnyField[typ.AnyType]] | type[typ.AnyField[lib.t.Any]]]

Return True if tp is typ[AnyField[Any]].

is_immutable_type(tp: type[Any]) lib.t.TypeGuard[type[typ.Immutable]]

Return True if tp is an immutable standardlib type.

is_literal(tp: type[Any] | Any) lib.t.TypeGuard[typ.Literal]

Return True if tp is a Literal.

is_mapping(obj: typ.MappingType | lib.t.Any) TypeGuard[typ.MappingType | typ.Mapping[lib.t.Any, lib.t.Any]]

Return True if obj is Mapping[lib.t.Any, lib.t.Any].

is_mapping_type(tp: type[typ.MappingType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.MappingType]]

Return True if tp is type[Mapping[lib.t.Any, lib.t.Any]].

is_none_type(tp: type[Any] | Any) lib.t.TypeGuard[type[typ.NoneType]]

Return True if tp is NoneType.

is_number_type(tp: type[typ.NumberType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[lib.numbers.Number] | type[typ.NumberType]]

Return True if tp is numbers.Number.

is_object(obj_: ObjectLike | type[Any] | Any) TypeGuard[ObjectLike]

Return True if obj_ is an Object.

is_params_type(tp: obj.SupportsParams[lib.Unpack[typ.ArgsType]] | lib.t.Any) TypeGuard[obj.SupportsParams[lib.Unpack[typ.ArgsType]] | obj.SupportsParams[lib.Unpack[tuple[lib.t.Any, ...]]]]

Return True if tp has type args.

is_primitive(obj: Any) lib.t.TypeGuard[typ.Primitive]

Return True if obj is a Primitive.

is_serialized_mapping(obj: Any | type[Any]) lib.t.TypeGuard[typ.Mapping[typ.Primitive, typ.Serial]]

Return True if obj is MappingProto[typ.Primitive, typ.Serial].

is_typed(any: type[typ.Typed] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.Typed]]

Return True if any is type-hinted.

is_typevar(obj: Any) TypeGuard[TypeVar]

Return True if obj is a TypeVar.

is_union(obj: Any) TypeGuard[UnionType]

Return True if obj is a UnionType.

is_variadic_array_type(tp: type[typ.VariadicArrayType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.VariadicArrayType]]

Return True if tp is type[VariadicArray].

is_wrapper_type(tp: typ.Wrapper | type[lib.t.Any] | lib.t.Any) TypeGuard[typ.Wrapper]

Return True if tp is Annotated | ClassVar | Final | InitVar.