diff --git a/pyproject.toml b/pyproject.toml index 57f608e..a416cfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,6 +117,11 @@ lint.select = [ "D103", "D104", ] +# allow `zip()` without passing the `strict` parameter for git submodule that +# is maintained in https://github.com/pyfar/sofa_conventions +"sofar/sofa_conventions/*" = [ + "B905", +] [tool.ruff.lint.pydocstyle] convention = "numpy" diff --git a/sofar/sofa.py b/sofar/sofa.py index 4bbee31..488e229 100644 --- a/sofar/sofa.py +++ b/sofar/sofa.py @@ -371,8 +371,10 @@ def inspect(self, file=None, issue_handling="print"): shape += (1, ) # make verbose shape, e.g., '(M=100, R=2, N=128, ' + # (not strict, because invalid objects can have more + # dimensions than defined and inspect should still work) shape_verbose = "(" - for s, d in zip(shape, dimension): + for s, d in zip(shape, dimension, strict=False): shape_verbose += f"{d}={s}, " # add shape information @@ -1409,7 +1411,7 @@ def _verify_unit(test, ref, unit_aliases): return False # check if units are valid - for unit_test, unit_ref in zip(units_test, units_ref): + for unit_test, unit_ref in zip(units_test, units_ref, strict=True): if unit_test not in unit_aliases \ or unit_aliases[unit_test] != unit_ref: return False diff --git a/sofar/sofastream.py b/sofar/sofastream.py index ee93dc3..6e0e3ed 100644 --- a/sofar/sofastream.py +++ b/sofar/sofastream.py @@ -439,7 +439,7 @@ def inspect(self, file=None): else: # make verbose shape, e.g., '(M=100, R=2, N=128, ' shape_verbose = "(" - for s, d in zip(shape, dimensions): + for s, d in zip(shape, dimensions, strict=True): shape_verbose += f"{d}={s}, " # add shape information diff --git a/sofar/update_conventions.py b/sofar/update_conventions.py index df64108..fee0395 100644 --- a/sofar/update_conventions.py +++ b/sofar/update_conventions.py @@ -440,7 +440,7 @@ def _check_congruency(save_dir=None, branch="master"): # save diverging files if save_dir is not None: - for subdir, d in zip(subdirs, data): + for subdir, d in zip(subdirs, data, strict=True): filename = os.path.join(save_dir, subdir, convention) with open(filename, "wb") as file: file.write(d) diff --git a/sofar/utils.py b/sofar/utils.py index 9c92284..e96455d 100644 --- a/sofar/utils.py +++ b/sofar/utils.py @@ -119,7 +119,7 @@ def _get_conventions(return_type, conventions_path=None): elif return_type == "name": return conventions elif return_type == "name_version": - return list(zip(conventions, versions)) + return list(zip(conventions, versions, strict=True)) elif return_type == "string": return conventions_str else: diff --git a/tests/test_utils.py b/tests/test_utils.py index 3bdb6e4..1370e30 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -143,7 +143,7 @@ def test__compile_conventions(): paths_test = _get_conventions( "path", os.path.join(temp_dir.name, "conventions")) - for path_ref, path_test in zip(paths_ref, paths_test): + for path_ref, path_test in zip(paths_ref, paths_test, strict=True): # load reference conventions with open(path_ref, "r") as file: