pipefunc.typing module#

Custom type hinting utilities for pipefunc.

class pipefunc.typing.NoAnnotation[source]#

Bases: object

Marker class for missing type annotations.

class pipefunc.typing.ArrayElementType[source]#

Bases: Generic[T]

Marker class for the element type of an annotated numpy array.

class pipefunc.typing.Array(shape, dtype=None, buffer=None, offset=0, strides=None, order=None)[source]#

Bases: Generic[T], ndarray[Any, dtype[object_]]

Annotated numpy array type hint with element type.

class pipefunc.typing.TypeCheckMemo(globals: dict[str, Any] | None, locals: dict[str, Any] | None, self_type: type | None = None)[source]#

Bases: NamedTuple

Named tuple to store memoization data for type checking.

globals: dict[str, Any] | None#

Alias for field number 0

locals: dict[str, Any] | None#

Alias for field number 1

self_type: type | None#

Alias for field number 2

pipefunc.typing.is_type_compatible(incoming_type, required_type, memo=None)[source]#

Check if the incoming type is compatible with the required type, resolving forward references.

Return type:

bool

pipefunc.typing.is_object_array_type(tp)[source]#

Check if the given type is similar to Array[T].

Specifically, this function checks if the type is either:

  1. Annotated[numpy.ndarray[Any, numpy.dtype[numpy.object_]], T]

  2. numpy.ndarray[Any, numpy.dtype[numpy.object_]]

Return type:

bool

class pipefunc.typing.Unresolvable(type_str)[source]#

Bases: object

Class to represent an unresolvable type hint.

pipefunc.typing.safe_get_type_hints(func, include_extras=False)[source]#

Safely get type hints for a function, resolving forward references.

Return type:

dict[str, Any]

pipefunc.typing.type_as_string(type_)[source]#

Get a string representation of a type.

Return type:

str