jgdv._abstract.protocols.pre_processable

Type Aliases

HookOverride

PreProcessResult

Protocols

PreProcessor_p

Protocol for things like Strang,

ProcessorHooks

Hooks a PreProcessor_p recognizes.

Module Contents

jgdv._abstract.protocols.pre_processable.HookOverride: TypeAlias = bool
jgdv._abstract.protocols.pre_processable.PreProcessResult: TypeAlias = tuple[str, InstanceData, PostInstanceData, Maybe[type[T]]]
class jgdv._abstract.protocols.pre_processable.PreProcessor_p[source]

Bases: Protocol

Protocol for things like Strang, whose metaclass preprocess the initialisation data before even __new__ is called.

Is used in a metatype.__call__ as:

cls._pre_process(...)
obj = cls.__new__(...)
obj.__init__(...)
obj._process()
obj._post_process()
return obj
post_process(obj, *, data) <Unknown>[source]
Parameters:
  • obj (T)

  • data (PostInstanceData)

Return type:

jgdv.Maybe[T]

pre_process(
cls,
input,
*args,
strict=False,
**kwargs,
) <Unknown>[source]
Parameters:
  • cls (type[T])

  • input (Any)

  • args (Any)

  • strict (bool)

  • kwargs (Any)

Return type:

PreProcessResult[T]

process(obj, *, data) <Unknown>[source]
Parameters:
  • obj (T)

  • data (PostInstanceData)

Return type:

jgdv.Maybe[T]

class jgdv._abstract.protocols.pre_processable.ProcessorHooks[source]

Bases: Protocol

Hooks a PreProcessor_p recognizes.

returning True as the first result value means the processor’s logic is not to be used. otherwise it is used, with the results from the hook

_post_process_h(*, data) <Unknown>[source]
Parameters:

data (PostInstanceData)

Return type:

jgdv.Maybe[tuple[HookOverride, jgdv.Maybe[T]]]

classmethod _pre_process_h(
input,
*args,
strict=False,
**kwargs,
) <Unknown>[source]
Parameters:
  • input (Any)

  • args (Any)

  • strict (bool)

  • kwargs (Any)

Return type:

jgdv.Maybe[tuple[bool, *PreProcessResult[T]]]

_process_h(*, data) <Unknown>[source]
Parameters:

data (PostInstanceData)

Return type:

jgdv.Maybe[tuple[HookOverride, jgdv.Maybe[T]]]