Skip to content

Registry

pydantic_pint.registry

Defines the global unit registry for PydanticPintQuantity.

app_registry module-attribute

app_registry = ApplicationRegistry(_DEFAULT_REGISTRY)

Pydantic Pint default application registry.

get_registry

get_registry()

Get the Pydantic Pint global registry.

RETURNS DESCRIPTION
UnitRegistry

The current global registry.

Source code in src/pydantic_pint/registry.py
def get_registry() -> pint.UnitRegistry:
    """Get the Pydantic Pint global registry.

    Returns:
        The current global registry.
    """
    return app_registry.get()

set_registry

set_registry(registry)

Set the Pydantic Pint global registry.

PARAMETER DESCRIPTION
registry

The new global registry.

TYPE: UnitRegistry

Source code in src/pydantic_pint/registry.py
def set_registry(registry: pint.UnitRegistry):
    """Set the Pydantic Pint global registry.

    Args:
        registry: The new global registry.
    """
    app_registry.set(registry)