diff options
author | Hernan Grecco <hgrecco@gmail.com> | 2023-05-11 15:06:04 -0300 |
---|---|---|
committer | Hernan Grecco <hgrecco@gmail.com> | 2023-05-11 15:06:04 -0300 |
commit | 94932f92de193fa5bbf60a6c30df47d4ce273e0f (patch) | |
tree | f30c0ab87c47841487ba3b6b7accbde06c35e2e0 | |
parent | 8426b391ff88dbfc7421ceda415ff2d7bcbcda37 (diff) | |
download | pint-94932f92de193fa5bbf60a6c30df47d4ce273e0f.tar.gz |
More typing improvements
-rw-r--r-- | pint/__init__.py | 1 | ||||
-rw-r--r-- | pint/facets/plain/quantity.py | 10 | ||||
-rw-r--r-- | pint/registry.py | 6 |
3 files changed, 9 insertions, 8 deletions
diff --git a/pint/__init__.py b/pint/__init__.py index ee80048..b8b5b43 100644 --- a/pint/__init__.py +++ b/pint/__init__.py @@ -29,6 +29,7 @@ from .formatting import formatter, register_unit_format from .registry import ApplicationRegistry, LazyRegistry, UnitRegistry from .util import logger, pi_theorem # noqa: F401 + # Default Quantity, Unit and Measurement are the ones # build in the default registry. Quantity = UnitRegistry.Quantity diff --git a/pint/facets/plain/quantity.py b/pint/facets/plain/quantity.py index 2f3de43..896dcfb 100644 --- a/pint/facets/plain/quantity.py +++ b/pint/facets/plain/quantity.py @@ -152,11 +152,11 @@ class PlainQuantity(Generic[MagnitudeT], PrettyIPython, SharedRegistryObject): # TODO: Check if this is still the case. return _unpickle_quantity, (PlainQuantity, self.magnitude, self._units) - # @overload - # def __new__( - # cls, value: T, units: UnitLike | None = None - # ) -> PlainQuantity[T]: - # ... + @overload + def __new__( + cls, value: MagnitudeT, units: UnitLike | None = None + ) -> PlainQuantity[MagnitudeT]: + ... @overload def __new__(cls, value: str, units: UnitLike | None = None) -> PlainQuantity[int]: diff --git a/pint/registry.py b/pint/registry.py index 964d8a5..5415ed2 100644 --- a/pint/registry.py +++ b/pint/registry.py @@ -14,7 +14,7 @@ from __future__ import annotations -from typing import Generic +from typing import Generic, TypeAlias from . import registry_helpers from . import facets @@ -98,8 +98,8 @@ class UnitRegistry( If None, the cache is disabled. (default) """ - Quantity = Quantity - Unit = Unit + Quantity: TypeAlias = Quantity + Unit: TypeAlias = Unit def __init__( self, |