summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeewis <keewis@posteo.de>2021-08-17 18:20:47 +0200
committerKeewis <keewis@posteo.de>2021-08-17 18:20:47 +0200
commit8c719483f6499eb860b4a0ec1a28aa23a736049e (patch)
treeee693c56b8eac25e9f94cf92a67ca85bdac6f090
parentdaae1085df859826e7e6b16795a8ec98cb6d2183 (diff)
downloadpint-8c719483f6499eb860b4a0ec1a28aa23a736049e.tar.gz
don't preprocess the unit spec
-rw-r--r--pint/formatting.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/pint/formatting.py b/pint/formatting.py
index 889dd4e..4a83377 100644
--- a/pint/formatting.py
+++ b/pint/formatting.py
@@ -387,11 +387,12 @@ def format_unit(unit, spec, **options):
else:
return "dimensionless"
- spec = _parse_spec(spec)
if not spec:
spec = "D"
- fmt = _FORMATTERS[spec]
+ fmt = _FORMATTERS.get(spec)
+ if fmt is None:
+ raise ValueError(f"Unknown conversion specified: {spec}")
return fmt(unit, **options)