Skip to content

Commit

Permalink
allow B905
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Jan 29, 2025
1 parent 50da1da commit cf2e7a0
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/stdatamodels/fits_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Check warning on line 338 in src/stdatamodels/fits_support.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/fits_support.py#L338

Added line #L338 was not covered by tests
for error in validator.descend(
item,
subschema,
Expand Down
2 changes: 1 addition & 1 deletion src/stdatamodels/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/stdatamodels/jwst/transforms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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):

Check warning on line 1484 in src/stdatamodels/jwst/transforms/models.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/transforms/models.py#L1484

Added line #L1484 was not covered by tests
x, y, z = self._func_map[ax](x, y, z, theta=ang)
x.shape = y.shape = z.shape = orig_shape

Expand Down Expand Up @@ -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.")

Check warning on line 1753 in src/stdatamodels/jwst/transforms/models.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/transforms/models.py#L1753

Added line #L1753 was not covered by tests
matrices = []
for angle, axis in zip(angles, axes_order):
for angle, axis in zip(angles, axes_order, strict=False):

Check warning on line 1755 in src/stdatamodels/jwst/transforms/models.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/transforms/models.py#L1755

Added line #L1755 was not covered by tests
matrix = np.zeros((3, 3), dtype=float)
if axis == "x":

Check warning on line 1757 in src/stdatamodels/jwst/transforms/models.py

View check run for this annotation

Codecov / codecov/patch

src/stdatamodels/jwst/transforms/models.py#L1757

Added line #L1757 was not covered by tests
mat = Rotation3D.rotation_matrix_from_angle(angle)
Expand Down
2 changes: 1 addition & 1 deletion src/stdatamodels/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/stdatamodels/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion tests/test_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cf2e7a0

Please sign in to comment.