Skip to content

Commit fb86a2f

Browse files
committed
Fix python 3.8 compatibility
1 parent 5daa308 commit fb86a2f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ucumvert/ucum_pint.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,15 @@ def find_matching_pint_definitions(report_file: Path | None = None) -> None:
313313
lookup_str = MAPPINGS_UCUM_TO_PINT.get(ucum_code, ucum_code)
314314
if is_in_registry(transformer_default, parsed_data):
315315
if section == "prefixes":
316-
pint_prefix = str(ureg_default(f"{ucum_code}m").units).removesuffix(
317-
"meter"
318-
)
316+
# Python 3.9+:
317+
# pint_prefix = str(ureg_default(f"{ucum_code}m").units).removesuffix(
318+
# "meter"
319+
# )
320+
# TODO replace next 3 lines by code above when 3.8 is no longer supported.
321+
pint_prefix = str(ureg_default(f"{ucum_code}m").units)
322+
if pint_prefix.endswith("meter"):
323+
pint_prefix = pint_prefix[: -len(pint_prefix)]
324+
319325
report.append(
320326
f"# {lookup_str:>10} --> {pint_prefix} (default registry)"
321327
)

0 commit comments

Comments
 (0)