Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
ENH: Require the iterables in a zip call to have equal length
Browse files Browse the repository at this point in the history
Require the iterables in a `zip` call to have equal length.

Fixes:
```
installing ruff...
--- .maint/update_authors.py
+++ .maint/update_authors.py
@@ -49,7 +49,7 @@
             break

         values = [v.strip() or None for v in line.split("|")][1:-1]
-        retval.append({k: v for k, v in zip(keys, values) if v})
+        retval.append({k: v for k, v in zip(keys, values, strict=False) if v})

     return retval

@@ -288,7 +288,7 @@
     print("Authors (%d):" % len(hits))
     print(
         "%s."
-        % "; ".join(["%s \\ :sup:`%s`\\ " % (i["name"], idx) for i, idx in zip(hits, aff_indexes)])
+        % "; ".join(["%s \\ :sup:`%s`\\ " % (i["name"], idx) for i, idx in zip(hits, aff_indexes, strict=False)])
     )

     print(

Would fix 2 errors.
```

raised for example in:
https://github.com/nipreps/eddymotion/actions/runs/8707149384/job/23881469441?pr=169#step:4:36

Documentation:
https://docs.astral.sh/ruff/rules/zip-without-explicit-strict/#zip-without-explicit-strict-b905
  • Loading branch information
jhlegarreta committed Apr 16, 2024
1 parent b1f70cc commit d8955fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .maint/update_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def read_md_table(md_text):
break

values = [v.strip() or None for v in line.split("|")][1:-1]
retval.append({k: v for k, v in zip(keys, values) if v})
retval.append({k: v for k, v in zip(keys, values, strict=True) if v})

return retval

Expand Down Expand Up @@ -288,7 +288,12 @@ def _aslist(value):
print("Authors (%d):" % len(hits))
print(
"%s."
% "; ".join(["%s \\ :sup:`%s`\\ " % (i["name"], idx) for i, idx in zip(hits, aff_indexes)])
% "; ".join(
[
"%s \\ :sup:`%s`\\ " % (i["name"], idx)
for i, idx in zip(hits, aff_indexes, strict=True)
]
)
)

print(
Expand Down

0 comments on commit d8955fe

Please sign in to comment.