Skip to content

Commit

Permalink
style: run 'pre-commit run --all-files'
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Mar 9, 2024
1 parent ed46b6e commit 3b1170c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 34 deletions.
8 changes: 3 additions & 5 deletions pint/facets/plain/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ def get_name(self, name_or_alias: str, case_sensitive: bool | None = None) -> st
prefix, unit_name, _ = candidates[0]
if len(candidates) > 1:
logger.warning(
"Parsing {} yield multiple results. "
"Options are: {!r}".format(name_or_alias, candidates)
f"Parsing {name_or_alias} yield multiple results. Options are: {candidates:!r}"
)

if prefix:
Expand All @@ -690,8 +689,7 @@ def get_symbol(self, name_or_alias: str, case_sensitive: bool | None = None) ->
prefix, unit_name, _ = candidates[0]
if len(candidates) > 1:
logger.warning(
"Parsing {} yield multiple results. "
"Options are: {!r}".format(name_or_alias, candidates)
f"Parsing {name_or_alias} yield multiple results. Options are: {candidates:!r}"
)

return self._prefixes[prefix].symbol + self._units[unit_name].symbol
Expand Down Expand Up @@ -1148,7 +1146,7 @@ def _yield_unit_triplets(

@staticmethod
def _dedup_candidates(
candidates: Iterable[tuple[str, str, str]]
candidates: Iterable[tuple[str, str, str]],
) -> tuple[tuple[str, str, str], ...]:
"""Helper of parse_unit_name.
Expand Down
5 changes: 3 additions & 2 deletions pint/facets/plain/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def __init__(self, units: UnitLike) -> None:
self._units = units._units
else:
raise TypeError(
"units must be of type str, Unit or "
"UnitsContainer; not {}.".format(type(units))
"units must be of type str, Unit or " "UnitsContainer; not {}.".format(
type(units)
)
)

def __copy__(self) -> PlainUnit:
Expand Down
35 changes: 17 additions & 18 deletions pint/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@

# Backwards compatiblity stuff
from .delegates.formatter.latex import (
vector_to_latex, # noqa
matrix_to_latex, # noqa
ndarray_to_latex_parts, # noqa
ndarray_to_latex, # noqa
latex_escape, # noqa
siunitx_format_unit, # noqa
_EXP_PATTERN, # noqa
vector_to_latex, # noqa: F401
matrix_to_latex, # noqa: F401
ndarray_to_latex_parts, # noqa: F401
ndarray_to_latex, # noqa: F401
latex_escape, # noqa: F401
siunitx_format_unit, # noqa: F401
_EXP_PATTERN, # noqa: F401
) # noqa
from .delegates.formatter._spec_helpers import (
FORMATTER, # noqa
_BASIC_TYPES, # noqa
parse_spec as _parse_spec, # noqa
_JOIN_REG_EXP as __JOIN_REG_EXP, # noqa,
_join, # noqa
_PRETTY_EXPONENTS, # noqa
pretty_fmt_exponent as _pretty_fmt_exponent, # noqa
extract_custom_flags, # noqa
remove_custom_flags, # noqa
split_format, # noqa
FORMATTER, # noqa: F401
_BASIC_TYPES, # noqa: F401
parse_spec as _parse_spec, # noqa: F401
_join, # noqa: F401
_PRETTY_EXPONENTS, # noqa: F401
pretty_fmt_exponent as _pretty_fmt_exponent, # noqa: F401
extract_custom_flags, # noqa: F401
remove_custom_flags, # noqa: F401
split_format, # noqa: F401
REGISTERED_FORMATTERS,
) # noqa
from .delegates.formatter._to_register import register_unit_format # noqa
from .delegates.formatter._to_register import register_unit_format # noqa: F401


def format_unit(unit, spec: str, registry=None, **options):
Expand Down
5 changes: 3 additions & 2 deletions pint/testsuite/test_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ def test_format_exponential_neg(self, func_registry, spec, expected):
],
)
def test_format_default(self, func_registry, spec, expected):
v, u = func_registry.Quantity(4.0, "s ** 2"), func_registry.Quantity(
0.1, "s ** 2"
v, u = (
func_registry.Quantity(4.0, "s ** 2"),
func_registry.Quantity(0.1, "s ** 2"),
)
m = func_registry.Measurement(v, u)
func_registry.default_format = spec
Expand Down
4 changes: 1 addition & 3 deletions pint/testsuite/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ def test_prod_numpy_func(self):
helpers.assert_quantity_equal(
np.prod(self.q, axis=axis), [3, 8] * self.ureg.m**2
)
helpers.assert_quantity_equal(
np.prod(self.q, where=where), 12 * self.ureg.m**3
)
helpers.assert_quantity_equal(np.prod(self.q, where=where), 12 * self.ureg.m**3)

with pytest.raises(DimensionalityError):
np.prod(self.q, axis=axis, where=where)
Expand Down
6 changes: 2 additions & 4 deletions pint/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ def column_echelon_form(
ItMatrix,
],
Matrix,
] = (
transpose if transpose_result else _noop
)
] = transpose if transpose_result else _noop

ech_matrix = matrix_apply(
transpose(matrix),
Expand Down Expand Up @@ -308,7 +306,7 @@ def pi_theorem(quantities: dict[str, Any], registry: UnitRegistry | None = None)


def solve_dependencies(
dependencies: dict[TH, set[TH]]
dependencies: dict[TH, set[TH]],
) -> Generator[set[TH], None, None]:
"""Solve a dependency graph.
Expand Down

0 comments on commit 3b1170c

Please sign in to comment.