Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it is better to add this to ruff exclude in line 78, as this is not in our hand.

]

[tool.ruff.lint.pydocstyle]
convention = "numpy"
Expand Down
6 changes: 4 additions & 2 deletions sofar/sofa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why False here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment righ above :) It's a user friendly way to make inspect work on sofa files that may have become invalid after an edit. This will be raised as an error in verify with an understandable error message.

shape_verbose += f"{d}={s}, "

# add shape information
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sofar/sofastream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sofar/update_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sofar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading