ft3.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
UnionandTypeVarexpansions automatically.Literalswill be returned as their values.Annotated,ClassVar,Final, andInitVarare 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
tuplefrom a passedtype,Union, orTypeVar.Literalswill be returned as their values.Annotated,ClassVar,Final, andInitVarare 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
TrueifobjisArray[lib.t.Any].
- is_array_of_object(obj: Any) lib.t.TypeGuard[typ.Array[typ.Object]]¶
Return
TrueifobjisArray[Object].
- is_array_of_obj_type(tp: type[Any]) lib.t.TypeGuard[type[typ.Array[typ.Object]]]¶
Return
Trueiftpistype[typ.Array[typ.Object]].
- is_array_type(tp: type[typ.ArrayType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.ArrayType]]¶
Return
Trueiftpistype[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
Trueiftpistype[bool].
- is_date_type(tp: type[Any] | Any) TypeGuard[type[date]]¶
Return
Trueiftpisdatetime.date.
- is_datetime_type(tp: type[Any] | Any) TypeGuard[type[datetime]]¶
Return
Trueiftpisdatetime.datetime.
- is_field(obj_: typ.AnyField[typ.AnyType] | lib.t.Any) TypeGuard[typ.AnyField[typ.AnyType] | typ.AnyField[lib.t.Any]]¶
Return
Trueifobj_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
Trueiftpistyp[AnyField[Any]].
- is_immutable_type(tp: type[Any]) lib.t.TypeGuard[type[typ.Immutable]]¶
Return
Trueif tp is an immutable standardlib type.
- is_literal(tp: type[Any] | Any) lib.t.TypeGuard[typ.Literal]¶
Return
Trueiftpis aLiteral.
- is_mapping(obj: typ.MappingType | lib.t.Any) TypeGuard[typ.MappingType | typ.Mapping[lib.t.Any, lib.t.Any]]¶
Return
TrueifobjisMapping[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
Trueiftpistype[Mapping[lib.t.Any, lib.t.Any]].
- is_none_type(tp: type[Any] | Any) lib.t.TypeGuard[type[typ.NoneType]]¶
Return
TrueiftpisNoneType.
- 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
Trueif tp isnumbers.Number.
- is_object(obj_: ObjectLike | type[Any] | Any) TypeGuard[ObjectLike]¶
Return
Trueifobj_is anObject.
- is_object_type(tp: Any) TypeGuard[type[objects.Object]]¶
Return
Trueiftpis anObject.
- is_optional_union_of_literal(obj: Any) TypeGuard[UnionType]¶
Return
Trueif obj is aOptional[UnionType]of all same typedLiteral.
- 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
Trueiftphas type args.
- is_primitive(obj: Any) lib.t.TypeGuard[typ.Primitive]¶
Return
Trueifobjis aPrimitive.
- is_serialized_mapping(obj: Any | type[Any]) lib.t.TypeGuard[typ.Mapping[typ.Primitive, typ.Serial]]¶
Return
TrueifobjisMappingProto[typ.Primitive, typ.Serial].
- is_typed(any: type[typ.Typed] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.Typed]]¶
Return
Trueifanyis type-hinted.
- is_typevar(obj: Any) TypeGuard[TypeVar]¶
Return
Trueif obj is aTypeVar.
- is_union(obj: Any) TypeGuard[UnionType]¶
Return
Trueif obj is aUnionType.
- is_union_of_literal(obj: Any) TypeGuard[UnionType]¶
Return
Trueif obj is aUnionTypeof all same typedLiteral.
- is_uuid_type(tp: type[Any] | Any) TypeGuard[UUID]¶
Return
TrueiftpisUUID.
- is_variadic_array_type(tp: type[typ.VariadicArrayType] | type[lib.t.Any] | lib.t.Any) lib.t.TypeGuard[type[typ.VariadicArrayType]]¶
Return
Trueiftpistype[VariadicArray].
- is_wrapper_type(tp: typ.Wrapper | type[lib.t.Any] | lib.t.Any) TypeGuard[typ.Wrapper]¶
Return
TrueiftpisAnnotated | ClassVar | Final | InitVar.