diff options
author | Hernan Grecco <hgrecco@gmail.com> | 2023-04-29 22:44:43 -0300 |
---|---|---|
committer | Hernan Grecco <hgrecco@gmail.com> | 2023-04-29 22:44:43 -0300 |
commit | 5d3d6299c9cfef5b62366482590edd3c241d9944 (patch) | |
tree | d064ef65d0f7fbcb78852296c87317bea2e261b8 /pint | |
parent | d4b3a7aee551f789cdb1528fc2ff66069a58f3eb (diff) | |
download | pint-5d3d6299c9cfef5b62366482590edd3c241d9944.tar.gz |
Run pyupgrade --py39-plus in all files except _vendor (again)
Diffstat (limited to 'pint')
-rw-r--r-- | pint/facets/measurement/objects.py | 2 | ||||
-rw-r--r-- | pint/facets/plain/registry.py | 2 | ||||
-rw-r--r-- | pint/testing.py | 10 | ||||
-rw-r--r-- | pint/util.py | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/pint/facets/measurement/objects.py b/pint/facets/measurement/objects.py index 6fa860c..aaf5750 100644 --- a/pint/facets/measurement/objects.py +++ b/pint/facets/measurement/objects.py @@ -133,7 +133,7 @@ class Measurement(PlainQuantity): # scientific notation ('e' or 'E' and sometimes 'g' or 'G'). mstr = mstr.replace("(", "").replace(")", " ") ustr = siunitx_format_unit(self.units._units, self._REGISTRY) - return r"\SI{}{{{}}}{{{}}}".format(opts, mstr, ustr) + return rf"\SI{opts}{{{mstr}}}{{{ustr}}}" # standard cases if "L" in spec: diff --git a/pint/facets/plain/registry.py b/pint/facets/plain/registry.py index 035d151..a35e508 100644 --- a/pint/facets/plain/registry.py +++ b/pint/facets/plain/registry.py @@ -464,7 +464,7 @@ class PlainRegistry(metaclass=RegistryMeta): if self._on_redefinition == "raise": raise RedefinitionError(key, type(value)) elif self._on_redefinition == "warn": - logger.warning("Redefining '{}' ({})".format(key, type(value))) + logger.warning(f"Redefining '{key}' ({type(value)})") target_dict[key] = value if casei_target_dict is not None: diff --git a/pint/testing.py b/pint/testing.py index 2f201f0..8e4f15f 100644 --- a/pint/testing.py +++ b/pint/testing.py @@ -36,10 +36,10 @@ def _get_comparable_magnitudes(first, second, msg): def assert_equal(first, second, msg=None): if msg is None: - msg = "Comparing {!r} and {!r}. ".format(first, second) + msg = f"Comparing {first!r} and {second!r}. " m1, m2 = _get_comparable_magnitudes(first, second, msg) - msg += " (Converted to {!r} and {!r}): Magnitudes are not equal".format(m1, m2) + msg += f" (Converted to {m1!r} and {m2!r}): Magnitudes are not equal" if isinstance(m1, ndarray) or isinstance(m2, ndarray): np.testing.assert_array_equal(m1, m2, err_msg=msg) @@ -60,15 +60,15 @@ def assert_equal(first, second, msg=None): def assert_allclose(first, second, rtol=1e-07, atol=0, msg=None): if msg is None: try: - msg = "Comparing {!r} and {!r}. ".format(first, second) + msg = f"Comparing {first!r} and {second!r}. " except TypeError: try: - msg = "Comparing {} and {}. ".format(first, second) + msg = f"Comparing {first} and {second}. " except Exception: msg = "Comparing" m1, m2 = _get_comparable_magnitudes(first, second, msg) - msg += " (Converted to {!r} and {!r})".format(m1, m2) + msg += f" (Converted to {m1!r} and {m2!r})" if isinstance(m1, ndarray) or isinstance(m2, ndarray): np.testing.assert_allclose(m1, m2, rtol=rtol, atol=atol, err_msg=msg) diff --git a/pint/util.py b/pint/util.py index 48e2249..a99d314 100644 --- a/pint/util.py +++ b/pint/util.py @@ -966,7 +966,7 @@ def getattr_maybe_raise(self, item): or len(item.lstrip("_")) == 0 or (item.startswith("_") and not item.lstrip("_")[0].isdigit()) ): - raise AttributeError("{!r} object has no attribute {!r}".format(self, item)) + raise AttributeError(f"{self!r} object has no attribute {item!r}") def iterable(y) -> bool: |