diff options
Diffstat (limited to 'pint')
-rw-r--r-- | pint/facets/plain/quantity.py | 9 | ||||
-rw-r--r-- | pint/registry.py | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/pint/facets/plain/quantity.py b/pint/facets/plain/quantity.py index 896dcfb..f6c27cf 100644 --- a/pint/facets/plain/quantity.py +++ b/pint/facets/plain/quantity.py @@ -17,7 +17,7 @@ import operator from typing import TYPE_CHECKING, Any, Callable, overload, Generic, TypeVar from collections.abc import Iterator, Sequence -from ..._typing import UnitLike, QuantityOrUnitLike, Magnitude +from ..._typing import UnitLike, QuantityOrUnitLike, Magnitude, Scalar from ...compat import ( HAS_NUMPY, _to_magnitude, @@ -47,6 +47,7 @@ if TYPE_CHECKING: import numpy as np # noqa MagnitudeT = TypeVar("MagnitudeT", bound=Magnitude) +ScalarT = TypeVar("ScalarT", bound=Scalar) T = TypeVar("T", bound=Magnitude) @@ -159,13 +160,13 @@ class PlainQuantity(Generic[MagnitudeT], PrettyIPython, SharedRegistryObject): ... @overload - def __new__(cls, value: str, units: UnitLike | None = None) -> PlainQuantity[int]: + def __new__(cls, value: str, units: UnitLike | None = None) -> PlainQuantity[Any]: ... @overload def __new__( # type: ignore[misc] - cls, value: Sequence, units: UnitLike | None = None - ) -> PlainQuantity[np.ndarray]: + cls, value: Sequence[ScalarT], units: UnitLike | None = None + ) -> PlainQuantity[Any]: ... # @overload diff --git a/pint/registry.py b/pint/registry.py index 5415ed2..fc20459 100644 --- a/pint/registry.py +++ b/pint/registry.py @@ -14,11 +14,12 @@ from __future__ import annotations -from typing import Generic, TypeAlias +from typing import Generic from . import registry_helpers from . import facets from .util import logger, pi_theorem +from .compat import TypeAlias # To build the Quantity and Unit classes |