typing

Useful type aliases and type variables for type-hints support.

Visit [PEP 484 Type Hints](https://peps.python.org/pep-0484/) for more help.

Variables endswith T are TypeVars for generic function signatures. They are defined to

  • accept constraint types(Any type when no type is given)

  • accept any subclass by using keyword bound

  • be parameter of Generic and subclass of Generic, espacially for invariant Collections(list,sequence and so on).

  • show more than once in generic functions to indicates that these types are exactly same.

Don’t import other classes, type aliases or type variables defined in haddock into this module. This may lead to circular import problem.

class haddock.core.typing.AnyT

Arbitrary type for generic function signatures.

alias of TypeVar(‘AnyT’)

haddock.core.typing.AtomsDict

A dict contains all kinds of residues’ atom type infomations (including non-standard residue and atom type).

Key is residue name, value is a list of the residue’s atom types.

haddock.core.typing.ExpertLevel

The expertise level of the parameters.`hidden` not inclued.

alias of Literal[‘all’, ‘easy’, ‘expert’, ‘guru’]

class haddock.core.typing.FilePathT

Generic type variable for file paths.

If the first annotated variable is str, the second annotated variable will be str instead of Path,vice versa.

alias of TypeVar(‘FilePathT’, bound=str | Path)

haddock.core.typing.ImgFormat

Supported image formats by plotly.

alias of Literal[‘png’, ‘pdf’, ‘svg’, ‘jpeg’, ‘webp’]

haddock.core.typing.LineIterSource

An Object who can generate lines in some way.

alias of Iterable[str] | str | Path

haddock.core.typing.ModuleParams

A dict contains modules’ parameters.

class haddock.core.typing.PT

Arbitrary parameter type for generic Callable signatures.

For py3.11+, ParamSpec and Concatenate may be more explict while making signatures longer.

alias of TypeVar(‘PT’)

haddock.core.typing.ParamDict

A dict contains parameters generated from config files or functions.

The keys are always str.

Can be called like dict and returns a python dict.

Examples

>>> ParamDict(a=1) == {'a':1}
True
>>> ParamDict({'a':1}) == {'a':1}
True
>>> ParamDict().setdefault('a', 1)
1
class haddock.core.typing.ParamDictT

Generic type of dict[str, Any] for generic function sigunature.

alias of TypeVar(‘ParamDictT’, bound=dict[str, Any])

haddock.core.typing.ParamMap

A mutable mapping object contains parameters generated from config files or functions.

The keys are always str.

alias of MutableMapping[str, Any]

class haddock.core.typing.ParamMapT

Generic type of MutableMapping[str, Any] for generic function sigunature.

alias of TypeVar(‘ParamMapT’, bound=MutableMapping[str, Any])

class haddock.core.typing.SupportsAdd(*args, **kwargs)[source]

Bases: Protocol

An ABC with one abstract method __add__.

Can be used in isinstance and issubclass.

Assuming that the operands and the result’s types are same for most common situations.

Examples

>>> isinstance(int, SupportsAdd)
True
class haddock.core.typing.SupportsAddT

TypeVar of SupportsAdd for Generic type check.

alias of TypeVar(‘SupportsAddT’, bound=SupportsAdd)

class haddock.core.typing.SupportsRun(*args, **kwargs)[source]

Bases: Protocol

An ABC with one abstract method run().

Can be used in isinstance and issubclass.

Examples

>>> from multiprocessing import Process
>>> isinstance(Process, SupportsRun)
True
run() Any[source]

Do something.

class haddock.core.typing.SupportsRunT

TypeVar of SupportsRun for Generic type check.

alias of TypeVar(‘SupportsRunT’, bound=SupportsRun)