From cf2e7a049ae216fdac4a4b883b2fc7196a3bcb6d Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 29 Jan 2025 13:20:22 -0500 Subject: [PATCH] allow B905 --- .ruff.toml | 6 +++--- src/stdatamodels/fits_support.py | 2 +- src/stdatamodels/history.py | 2 +- src/stdatamodels/jwst/transforms/models.py | 6 +++--- src/stdatamodels/properties.py | 2 +- src/stdatamodels/util.py | 2 +- tests/test_fits.py | 4 +++- tests/test_history.py | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index ed57f920..f3041dcf 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -51,10 +51,10 @@ ignore = [ "UP015", # unnecessary open(file, "r"). no harm being explicit "TRY003", # prevents custom exception messages not defined in exception itself. "ISC001", # single line implicit string concatenation. formatter recommends ignoring this. + # longer term fix + "B028", # warnings need stack level, this is non-trivial to determine + "B904", # raise ... from ?, when and where do we want to not use the default chain? # to fix - "B028", - "B904", - "B905", "C401", "C402", "C405", diff --git a/src/stdatamodels/fits_support.py b/src/stdatamodels/fits_support.py index b6886f15..a1cadb46 100644 --- a/src/stdatamodels/fits_support.py +++ b/src/stdatamodels/fits_support.py @@ -335,7 +335,7 @@ def _fits_item_recurse(fits_context, validator, items, instance, schema): yield error else: # We don't do the index trick on "tuple validated" sequences - for (index, item), subschema in zip(enumerate(instance), items): + for (index, item), subschema in zip(enumerate(instance), items, strict=False): for error in validator.descend( item, subschema, diff --git a/src/stdatamodels/history.py b/src/stdatamodels/history.py index e7dd2a44..f8de17d6 100644 --- a/src/stdatamodels/history.py +++ b/src/stdatamodels/history.py @@ -54,7 +54,7 @@ def __eq__(self, other): if len(self) != len(other): return False - for self_entry, other_entry in zip(self._entries, other): + for self_entry, other_entry in zip(self._entries, other, strict=False): if isinstance(other_entry, str): if self_entry.get("description") != other_entry: return False diff --git a/src/stdatamodels/jwst/transforms/models.py b/src/stdatamodels/jwst/transforms/models.py index b56a5aad..c339a5db 100644 --- a/src/stdatamodels/jwst/transforms/models.py +++ b/src/stdatamodels/jwst/transforms/models.py @@ -445,7 +445,7 @@ def __init__(self, spectral_orders, models): """ RA and DEC coordinates and wavelength""" self.spectral_orders = spectral_orders - self.models = dict(zip(spectral_orders, models)) + self.models = dict(zip(spectral_orders, models, strict=False)) def get_model(self, spectral_order): return self.models[spectral_order] @@ -1481,7 +1481,7 @@ def evaluate(self, x, y, z, angles): # Note: If the original shape was () (an array scalar) convert to a # 1-element 1-D array on output for consistency with most other models orig_shape = x.shape or (1,) - for ang, ax in zip(angles[0], self.axes_order): + for ang, ax in zip(angles[0], self.axes_order, strict=False): x, y, z = self._func_map[ax](x, y, z, theta=ang) x.shape = y.shape = z.shape = orig_shape @@ -1752,7 +1752,7 @@ def _compute_matrix(angles, axes_order): if len(angles) != len(axes_order): raise InputParameterError("Number of angles must equal number of axes in axes_order.") matrices = [] - for angle, axis in zip(angles, axes_order): + for angle, axis in zip(angles, axes_order, strict=False): matrix = np.zeros((3, 3), dtype=float) if axis == "x": mat = Rotation3D.rotation_matrix_from_angle(angle) diff --git a/src/stdatamodels/properties.py b/src/stdatamodels/properties.py index 646fea20..fc8d6c68 100644 --- a/src/stdatamodels/properties.py +++ b/src/stdatamodels/properties.py @@ -60,7 +60,7 @@ def _cast(val, schema): if "allow_extra_columns" in schema: allow_extra_columns = schema["allow_extra_columns"] - for t, v in zip(schema["datatype"], val[0]): + for t, v in zip(schema["datatype"], val[0], strict=False): if not isinstance(t, Mapping): continue diff --git a/src/stdatamodels/util.py b/src/stdatamodels/util.py index 401ed25d..118695f4 100644 --- a/src/stdatamodels/util.py +++ b/src/stdatamodels/util.py @@ -178,7 +178,7 @@ def _safe_asanyarray(a, dtype): # a FITS_rec with a pseudo-unsigned column. # See https://github.com/astropy/astropy/issues/12112 result = np.zeros(a.shape, dtype=dtype) - for old_col, new_col in zip(a.dtype.names, result.dtype.names): + for old_col, new_col in zip(a.dtype.names, result.dtype.names, strict=False): result[new_col] = a[old_col] return result diff --git a/tests/test_fits.py b/tests/test_fits.py index 96fa38e5..e9c43b9e 100644 --- a/tests/test_fits.py +++ b/tests/test_fits.py @@ -336,7 +336,9 @@ def test_table_with_unsigned_int(tmp_path): uint32_arr[0] = uint32_info.min uint32_arr[-1] = uint32_info.max - test_table = np.array(list(zip(float64_arr, uint32_arr)), dtype=dm.test_table.dtype) + test_table = np.array( + list(zip(float64_arr, uint32_arr, strict=False)), dtype=dm.test_table.dtype + ) def assert_table_correct(model): for idx, (col_name, col_data) in enumerate( diff --git a/tests/test_history.py b/tests/test_history.py index 0fe8e50a..55b70746 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -37,7 +37,7 @@ def test_historylist_methods(): assert len(h1) == 3, "Length of extended history list" assert h1 == info, "Contents of extended history list" - for entry, item in zip(h1, info): + for entry, item in zip(h1, info, strict=False): assert entry["description"] == item, "Iterate over history list" h1.clear()