From 3b1170c896f10a075cf384c9452aa56794feaca9 Mon Sep 17 00:00:00 2001 From: Hernan Grecco Date: Fri, 8 Mar 2024 21:31:08 -0300 Subject: [PATCH] style: run 'pre-commit run --all-files' --- pint/facets/plain/registry.py | 8 +++---- pint/facets/plain/unit.py | 5 +++-- pint/formatting.py | 35 +++++++++++++++--------------- pint/testsuite/test_measurement.py | 5 +++-- pint/testsuite/test_numpy.py | 4 +--- pint/util.py | 6 ++--- 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/pint/facets/plain/registry.py b/pint/facets/plain/registry.py index bddecadc3..234f7cb36 100644 --- a/pint/facets/plain/registry.py +++ b/pint/facets/plain/registry.py @@ -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: @@ -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 @@ -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. diff --git a/pint/facets/plain/unit.py b/pint/facets/plain/unit.py index fba6a7c76..0ee05abbc 100644 --- a/pint/facets/plain/unit.py +++ b/pint/facets/plain/unit.py @@ -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: diff --git a/pint/formatting.py b/pint/formatting.py index 94eb57cf6..7732a9780 100644 --- a/pint/formatting.py +++ b/pint/formatting.py @@ -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): diff --git a/pint/testsuite/test_measurement.py b/pint/testsuite/test_measurement.py index 8a98128ef..a379e99ba 100644 --- a/pint/testsuite/test_measurement.py +++ b/pint/testsuite/test_measurement.py @@ -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 diff --git a/pint/testsuite/test_numpy.py b/pint/testsuite/test_numpy.py index 15e56358a..50167f8ff 100644 --- a/pint/testsuite/test_numpy.py +++ b/pint/testsuite/test_numpy.py @@ -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) diff --git a/pint/util.py b/pint/util.py index 659a90298..6cddce7a8 100644 --- a/pint/util.py +++ b/pint/util.py @@ -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), @@ -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.