diff --git a/pint/__init__.py b/pint/__init__.py index ee80048e1..b8b5b43a1 100644 --- a/pint/__init__.py +++ b/pint/__init__.py @@ -29,6 +29,7 @@ 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 2f3de43b9..896dcfbf9 100644 --- a/pint/facets/plain/quantity.py +++ b/pint/facets/plain/quantity.py @@ -152,11 +152,11 @@ def __reduce__(self) -> tuple[type, Magnitude, UnitsContainer]: # 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 964d8a5e8..5415ed2b3 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,