Skip to content

Commit

Permalink
Make D the default formatter if spec is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Jan 19, 2024
1 parent ad0cd73 commit a1eee0a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pint/delegates/formatter/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self) -> None:

def get_formatter(self, spec: str):
if spec == "":
return self._formatters["raw"]
return self._formatters["D"]
for k, v in self._formatters.items():
if k in spec:
return v
Expand All @@ -70,13 +70,15 @@ def get_formatter(self, spec: str):
def format_magnitude(
self, magnitude: Magnitude, mspec: str = "", **babel_kwds: Unpack[BabelKwds]
) -> str:
mspec = mspec or self.default_format
return self.get_formatter(mspec).format_magnitude(
magnitude, mspec, **babel_kwds
)

def format_unit(
self, unit: PlainUnit, uspec: str = "", **babel_kwds: Unpack[BabelKwds]
) -> str:
uspec = uspec or self.default_format
return self.get_formatter(uspec).format_unit(unit, uspec, **babel_kwds)

def format_quantity(
Expand Down

0 comments on commit a1eee0a

Please sign in to comment.