argdigest.contrib package#

Submodules#

argdigest.contrib.beartype_support module#

Optional beartype support.

Usage in a user library:

from argdigest.contrib.beartype_support import beartype_digest

@beartype_digest(map={…}) def fn(…):

argdigest.contrib.beartype_support.beartype_digest(*, kind=None, rules=None, map=None, **kwargs)[source]#
Parameters:
  • kind (str | None)

  • rules (list[str] | None)

  • map (dict[str, dict] | None)

  • kwargs (Any)

argdigest.contrib.pydantic_support module#

Helpers to integrate ArgDigest with pydantic (v2-style).

argdigest.contrib.pydantic_support.model_from_dict(model_cls, data)[source]#
Parameters:
  • model_cls (Type['BaseModel'])

  • data (Any)

Return type:

BaseModel

argdigest.contrib.pydantic_support.pydantic_pipeline(model_cls)[source]#

Creates an ArgDigest pipeline function from a Pydantic model. The returned function takes (value, ctx) and returns a validated model instance.

Parameters:

model_cls (Type['BaseModel'])

Return type:

callable

argdigest.contrib.pyunitwizard_support module#

Integration with PyUnitWizard for physical quantity validation and standardization.

argdigest.contrib.pyunitwizard_support.check(dimensionality=None, value_type=None, shape=None, unit=None)[source]#

Returns a pipeline function that uses puw.check() to validate the input.

Parameters:
  • dimensionality (Dict[str, int] | None)

  • value_type (Any | None)

  • shape (tuple | None)

  • unit (str | None)

Return type:

Callable[[Any, Any], Any]

argdigest.contrib.pyunitwizard_support.context(**kwargs)[source]#

Context manager that delegates to pyunitwizard.context if available. If PUW is not installed, it yields without doing anything (unless kwargs are passed, then warning/error?). Assuming if user passes puw_context, they expect PUW to work.

Parameters:

kwargs (Any)

argdigest.contrib.pyunitwizard_support.convert(to_unit, to_form=None)[source]#

Returns a pipeline function that converts the quantity to a specific unit/form.

Parameters:
  • to_unit (str)

  • to_form (str | None)

Return type:

Callable[[Any, Any], Any]

argdigest.contrib.pyunitwizard_support.is_quantity()[source]#
Return type:

Callable[[Any, Any], Any]

argdigest.contrib.pyunitwizard_support.standardize()[source]#

Returns a pipeline function that calls puw.standardize(). It respects the global pyunitwizard configuration (form/units).

Return type:

Callable[[Any, Any], Any]

Module contents#