Skip to content

What does registry=None mean in custom formatter ? #2009

@aulemahal

Description

@aulemahal

Hi!

With pint 0.24, the internal workings of register_unit_format have changed and the registry argument of the wrapped function can now be "None". I do not see in the doc the meaning of that new possible value. Wouldn't a Unit object always be related to a registry, even if it's the default one ?

This is causing issues in cf-xarray (and downstream) for example (xarray-contrib/cf-xarray#507) where we used registry to convert the UnitContainer back to a Unit (see https://github.com/xarray-contrib/cf-xarray/blob/24dd81b2748db59c3ede68735a200b63b8a3d2d2/cf_xarray/units.py#L17-L38)

EDIT: Also, the way register_unit_format is written, wouldn't registry always be None ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions