Skip to content

Commit

Permalink
More typing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed May 11, 2023
1 parent 8426b39 commit 94932f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions pint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pint/facets/plain/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
6 changes: 3 additions & 3 deletions pint/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import Generic
from typing import Generic, TypeAlias

from . import registry_helpers
from . import facets
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 94932f9

Please sign in to comment.