Skip to content

Commit

Permalink
Drop pint type-hinting until it is properly supported
Browse files Browse the repository at this point in the history
hgrecco/pint#1166
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Apr 2, 2024
1 parent 9b73d02 commit 7404b91
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
from tmt.utils import SpecBasedContainer

if TYPE_CHECKING:
import importlib.metadata

from packaging import version
from pint import Quantity

# Using TypeAlias and typing-extensions under the guard of TYPE_CHECKING,
Expand All @@ -66,15 +63,10 @@
else:
from typing_extensions import TypeAlias

# Note, type-hinting is not properly supported in pint. Change to `Quantity[int]` when
# supported (https://github.com/hgrecco/pint/issues/1166)
#: A type of values describing sizes of things like storage or RAM.
if version.parse(importlib.metadata.version("pint")) >= version.parse("0.20"):
# Note, type-hinting is not properly supported in pint
# https://github.com/hgrecco/pint/issues/1166
Size: TypeAlias = Quantity
else:
# But this one used to work < 0.20 ¯\_(ツ)_/¯
# https://github.com/hgrecco/pint/pull/1259
Size: TypeAlias = 'Quantity[int]'
Size: TypeAlias = Quantity

#: Unit registry, used and shared by all code.
UNITS = pint.UnitRegistry()
Expand Down

0 comments on commit 7404b91

Please sign in to comment.