nanoutils.typing_utils¶
Types related to the builtin typing
module.
Contains aliases for python >= 3.8
exclusive objects related to typing.
See also
The typing module: Support for gradual typing as defined by PEP 484.
At large scale, the structure of the module is following:
Imports and exports, all public names should be explicitly added to
__all__
.Internal helper functions: these should never be used in code outside this module.
_SpecialForm
and its instances (special forms):Any
,NoReturn
,ClassVar
,Union
andOptional
.Two classes whose instances can be type arguments in addition to types:
ForwardRef
andTypeVar
.The core of internal generics API: _GenericAlias and _VariadicGenericAlias, the latter is currently only used by
Tuple
andCallable
. All subscripted types likeX[int]
,Union[int, str]
, etc., are instances of either of these classes.The public counterpart of the generics API consists of two classes:
Generic
andProtocol
.Public helper functions:
get_type_hints()
,overload()
,cast()
,no_type_check()
,no_type_check_decorator()
.Generic aliases for
collections.abc
ABCs and few additional protocols.Special types:
NewType()
,NamedTuple
andTypedDict
.
Index¶
Special typing form to define literal types (a.k.a. value types). |
|
Special typing construct to indicate final names to type checkers. |
|
A decorator to indicate final methods and final classes. |
|
Base class for protocol classes. |
|
An ABC with one abstract method |
|
A simple typed name space. At runtime it is equivalent to a plain |
|
Mark a protocol class as a runtime protocol, so that it an be used with |
|
An annotation for path-like objects. |
|
Objects that can be converted to arrays (see |
|
Objects that can be converted to dtypes (see |
|
|
Objects that can serve as valid array shapes. |