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
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Jun 18, 2024
1 parent c39a788 commit 3188424
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3188424

Please sign in to comment.