summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHernan Grecco <hgrecco@gmail.com>2023-05-11 15:15:45 -0300
committerHernan Grecco <hgrecco@gmail.com>2023-05-11 15:15:45 -0300
commit623d00443bee13c227fdf37ba8843c3233d15328 (patch)
tree403c05af9d3355c141a1103d40aa3c37f937b630
parent94932f92de193fa5bbf60a6c30df47d4ce273e0f (diff)
downloadpint-623d00443bee13c227fdf37ba8843c3233d15328.tar.gz
Fix imports for Python 3.9
-rw-r--r--pint/facets/plain/quantity.py9
-rw-r--r--pint/registry.py3
-rw-r--r--requirements_docs.txt1
3 files changed, 8 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
diff --git a/requirements_docs.txt b/requirements_docs.txt
index 38bb8a5..8f44109 100644
--- a/requirements_docs.txt
+++ b/requirements_docs.txt
@@ -19,3 +19,4 @@ pygments>=2.4
sphinx-book-theme==0.3.3
sphinx_copybutton
sphinx_design
+typing_extensions