diff options
author | Keewis <keewis@posteo.de> | 2021-08-18 02:16:18 +0200 |
---|---|---|
committer | Keewis <keewis@posteo.de> | 2021-08-18 02:16:18 +0200 |
commit | 139ce1655f5e78419308f96003bc2b9331b92b25 (patch) | |
tree | 1a5bc730b17802fa909e304e363a76d9d15a2028 | |
parent | 60bcc66e666db06f1aac38e9058d8444c55a695d (diff) | |
download | pint-139ce1655f5e78419308f96003bc2b9331b92b25.tar.gz |
preprocess the default format
-rw-r--r-- | pint/unit.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pint/unit.py b/pint/unit.py index e78023b..8651900 100644 --- a/pint/unit.py +++ b/pint/unit.py @@ -20,7 +20,7 @@ from ._typing import UnitLike from .compat import NUMERIC_TYPES, babel_parse, is_upcast_type from .definitions import UnitDefinition from .errors import DimensionalityError -from .formatting import format_unit +from .formatting import extract_custom_flags, format_unit from .util import PrettyIPython, SharedRegistryObject, UnitsContainer if TYPE_CHECKING: @@ -80,7 +80,7 @@ class Unit(PrettyIPython, SharedRegistryObject): return "<Unit('{}')>".format(self._units) def __format__(self, spec) -> str: - spec = spec or self.default_format + spec = spec or extract_custom_flags(self.default_format) if "~" in spec: if not self._units: return "" @@ -97,7 +97,7 @@ class Unit(PrettyIPython, SharedRegistryObject): return format_unit(units, spec, registry=self._REGISTRY) def format_babel(self, spec="", locale=None, **kwspec: Any) -> str: - spec = spec or self.default_format + spec = spec or extract_custom_flags(self.default_format) if "~" in spec: if self.dimensionless: |