From a3b11c4a43eedf6fb18ed592ad5f708a10583931 Mon Sep 17 00:00:00 2001 From: Ruth Comer <ruth.comer@metoffice.gov.uk> Date: Tue, 14 Nov 2023 15:52:47 +0000 Subject: [PATCH] Ruth fixes for unsafe fixes --- cf_units/__init__.py | 7 +++---- cf_units/tests/test_coding_standards.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cf_units/__init__.py b/cf_units/__init__.py index 06debc0c..214503a1 100644 --- a/cf_units/__init__.py +++ b/cf_units/__init__.py @@ -929,7 +929,7 @@ def title(self, value): dt = self.num2date(value) result = dt.strftime("%Y-%m-%d %H:%M:%S") else: - result = f"{str(value)} {self}" + result = f"{value} {self}" return result @property @@ -1792,9 +1792,8 @@ def convert(self, value, other, ctype=FLOAT64, inplace=False): # Strict type check of numpy array. if result.dtype.type not in (np.float32, np.float64): raise TypeError( - "Expect a numpy array of '{}' or '{}'".format(*np.float32), - np.float64, - ) + "Expect a numpy array of " + f"'{np.float32}' or '{np.float64}'") ctype = result.dtype.type # Utilise global convenience dictionary # _cv_convert_array to convert our array in 1d form diff --git a/cf_units/tests/test_coding_standards.py b/cf_units/tests/test_coding_standards.py index ff4d0364..660293aa 100644 --- a/cf_units/tests/test_coding_standards.py +++ b/cf_units/tests/test_coding_standards.py @@ -109,7 +109,7 @@ def test_license_headers(self): ) failed = False - for fname, _last_change in sorted(last_change_by_fname.items()): + for fname in sorted(last_change_by_fname): full_fname = os.path.join(REPO_DIR, fname) if ( full_fname.endswith(".py")