Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Transformation type protocol #1801 #1805

Merged
merged 4 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions pint/facets/context/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@

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
from ...util import UnitsContainer, to_units_container
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:
...


Expand Down