typing
Various type annotation aids.
Type Hints
Type hint for objects that represent filesystem paths. |
|
Invariant |
|
Type hint for numbers. |
|
The type of methods of some built-in data types and base classes. |
|
The type of bound methods of some built-in data types and base classes. |
|
The type of methods of some built-in data types. |
|
The type of unbound class methods of some built-in data types. |
-
PathLike Type hint for objects that represent filesystem paths.
See also
-
PathType= TypeVar(PathType, str, Path, PathLike) Type:
TypeVarInvariant
TypeVarconstrained tostr,pathlib.Pathandos.PathLike.Type variable for objects that represent filesystem paths.
New in version 2.2.0.
See also
-
AnyNumber Type hint for numbers.
Changed in version 0.4.6: Moved from
domdf_python_tools.pagesizes
-
WrapperDescriptorType The type of methods of some built-in data types and base classes, such as
object.__init__()orobject.__lt__().New in version 0.8.0.
-
MethodWrapperType The type of bound methods of some built-in data types and base classes. For example, it is the type of
object().__str__.New in version 0.8.0.
-
MethodDescriptorType The type of methods of some built-in data types, such as
str.join().New in version 0.8.0.
-
ClassMethodDescriptorType The type of unbound class methods of some built-in data types, such as
dict.__dict__['fromkeys'].New in version 0.8.0.
Protocols
|
|
|
|
|
|
Invariant |
|
|
|
|
|
|
|
|
|
|
-
protocol
JsonLibrary[source] Bases:
Protocoltyping.Protocolfor libraries that implement the same API asjson.Useful for annotating functions which take a JSON serialisation-deserialisation library as an argument.
Classes that implement this protocol must have the following methods / attributes:
-
static
dumps(obj, *, skipkeys=..., ensure_ascii=..., check_circular=..., allow_nan=..., cls=..., indent=..., separators=..., default=..., sort_keys=..., **kwds)[source] Serialize
objto a JSON formattedstr.
-
static
loads(s, *, cls=..., object_hook=..., parse_float=..., parse_int=..., parse_constant=..., object_pairs_hook=..., **kwds)[source] Deserialize
sto a Python object.
-
static
-
protocol
HasHead[source] Bases:
Protocoltyping.Protocolfor classes that have aheadmethod.This includes
pandas.DataFrameandpandas.Series.New in version 0.8.0.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
-
protocol
String[source] Bases:
ProtocolProtocolfor classes that implement__str__.Changed in version 0.8.0: Moved from
domdf_python_tools.stringlist.This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
-
protocol
FrameOrSeries New in version 1.0.0.
Classes that implement this protocol must have the following methods / attributes:
-
protocol
SupportsIndex[source] Bases:
Protocoltyping.Protocolfor classes that support__index__.New in version 2.0.0.
Classes that implement this protocol must have the following methods / attributes:
-
protocol
SupportsLessThan[source] Bases:
Protocoltyping.Protocolfor classes that support__lt__.New in version 3.0.0.
Classes that implement this protocol must have the following methods / attributes:
-
protocol
SupportsLessEqual[source] Bases:
Protocoltyping.Protocolfor classes that support__le__.New in version 3.0.0.
Classes that implement this protocol must have the following methods / attributes:
-
protocol
SupportsGreaterThan[source] Bases:
Protocoltyping.Protocolfor classes that support__gt__.New in version 3.0.0.
Classes that implement this protocol must have the following methods / attributes:
Utility Functions
-
check_membership(obj, type_)[source] Check if the type of
objis one of the types in atyping.Union,typing.Sequenceetc.- Parameters
obj (
Any) – The object to check the type oftype_ (
Union[Type,object]) – ATypethat has members, such as atyping.List,typing.Unionortyping.Sequence.
- Return type