Skip to content

Commit fc5b5b0

Browse files
committed
AssociationsTool: stop shadowing the gettext _ with a loop variable
_build_with_progress used `for _ in range(batch_size)`, which makes _ a local variable throughout the whole method (Python binds it at compile time). That shadows the module-level `_ = _trans.gettext`, so: - the except handler at the top of the method, LOG.error(_("Error initializing data: %s") % str(e)), runs before the loop assigns _ and raises UnboundLocalError; and - the in-loop handler LOG.warning(_("Error processing person %s: %s" % ...)) calls _ after the loop bound it to an int, raising TypeError. Both fire only on the error paths, so they slipped through. The loop counter is unused; rename it to _batch_step so _ resolves to the module gettext everywhere. ruff (E9,F63,F7,F82) is clean on the module. This also clears the F82x lint error PR 820's ruff gate reports on the current tree.
1 parent 23187c6 commit fc5b5b0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

AssociationsTool/associationstool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _build_with_progress(self) -> bool:
184184

185185
# Process next batch
186186
batch_size = 50
187-
for _ in range(batch_size):
187+
for _batch_step in range(batch_size):
188188
if self._build_index >= len(self._plist):
189189
# Done processing
190190
self.stats_list = self._build_data

0 commit comments

Comments
 (0)