diff --git a/CHANGES b/CHANGES index 597000896..278b8ce41 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ Pint Changelog 0.23 (unreleased) ----------------- +- Fixed Transformation type protocol. + (PR #1805) - Documented to_preferred and created added an autoautoconvert_to_preferred registry option. (PR #1803) diff --git a/pint/facets/context/objects.py b/pint/facets/context/objects.py index 4ab2f1d52..9001e9666 100644 --- a/pint/facets/context/objects.py +++ b/pint/facets/context/objects.py @@ -10,7 +10,7 @@ import weakref from collections import ChainMap, defaultdict -from typing import Any, Callable, Protocol, Generic, Optional +from typing import Any, Callable, Protocol, Generic, Optional, TYPE_CHECKING from collections.abc import Iterable from ...facets.plain import UnitDefinition, PlainQuantity, PlainUnit, MagnitudeT @@ -18,9 +18,14 @@ from .definitions import ContextDefinition from ..._typing import Magnitude +if TYPE_CHECKING: + from ...registry import UnitRegistry + class Transformation(Protocol): - def __call__(self, value: Magnitude, **kwargs: Any) -> Magnitude: + def __call__( + self, ureg: UnitRegistry, value: Magnitude, **kwargs: Any + ) -> Magnitude: ...