From 3188424f782a04a50a507f6ca3e2902762cac0a2 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Wed, 6 Mar 2024 11:39:45 +0100 Subject: [PATCH] Drop pint type-hinting until it is properly supported Signed-off-by: Cristian Le --- pyproject.toml | 3 ++- tmt/hardware.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4fe58e62ab..f815aafcef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -249,7 +249,8 @@ ignore = [ "tmt/convert.py", "tmt/lint.py", "tmt/queue.py", - "tmt/utils.py" + "tmt/utils.py", + "tmt/hardware.py", # pyright does not pick up pint's _typing.py or something :/ ] pythonVersion = "3.9" diff --git a/tmt/hardware.py b/tmt/hardware.py index fa8bb0fa34..9799fe849b 100644 --- a/tmt/hardware.py +++ b/tmt/hardware.py @@ -64,7 +64,9 @@ from typing_extensions import TypeAlias #: A type of values describing sizes of things like storage or RAM. - Size: TypeAlias = 'Quantity[int]' + # Note: type-hinting is a bit wonky with pyright + # https://github.com/hgrecco/pint/issues/1166 + Size: TypeAlias = Quantity #: Unit registry, used and shared by all code. UNITS = pint.UnitRegistry() @@ -558,7 +560,7 @@ def _from_specification( if not isinstance( value, pint.Quantity): # type: ignore[reportUnnecessaryIsInstance,unused-ignore] - value = pint.Quantity(value) + value = pint.Quantity(value) # pyright: ignore[reportAssignmentType] elif as_cast is not None: value = as_cast(raw_value)