Skip to content

[v3-3-test] Enable ruff B023 (function-uses-loop-variable) and fix violations (#70640) - #72273

Merged
potiuk merged 1 commit into
v3-3-testfrom
backport-af0a377-v3-3-test
Aug 29, 2026
Merged

[v3-3-test] Enable ruff B023 (function-uses-loop-variable) and fix violations (#70640)#72273
potiuk merged 1 commit into
v3-3-testfrom
backport-af0a377-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

B023 catches the late-binding closure-over-loop-variable footgun where
a function defined inside a loop captures the loop variable by
reference, so every function in the resulting list sees the same
(final) value — a classic silent-bug source in Python
(https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result).

The one user-visible fix is in providers/standard/.../triggers/file.py,
where the FileTrigger's os.walk lambda was dispatched to a worker
thread via anyio.to_thread.run_sync while the outer glob iteration
could advance, potentially walking the wrong path.

The rest are pre-existing latent-bug or false-positive sites in a
migration script, breeze translation helpers, sphinx extensions, a
system-test example DAG, the SMTP OAuth2 auth callback, secrets_masker
subclass compat shim, and two provider unit tests — fixed by binding
the loop-derived variable as a default argument on the inner function
or lambda.
(cherry picked from commit af0a377)

Co-authored-by: Deepak kumar deepakkumar@meta.com
Co-authored-by: Jarek Potiuk jarek@potiuk.com

…olations (#70640)
B023 catches the late-binding closure-over-loop-variable footgun where
a function defined inside a loop captures the loop variable by
reference, so every function in the resulting list sees the same
(final) value — a classic silent-bug source in Python
(https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result).
The one user-visible fix is in providers/standard/.../triggers/file.py,
where the FileTrigger's os.walk lambda was dispatched to a worker
thread via anyio.to_thread.run_sync while the outer glob iteration
could advance, potentially walking the wrong path.
The rest are pre-existing latent-bug or false-positive sites in a
migration script, breeze translation helpers, sphinx extensions, a
system-test example DAG, the SMTP OAuth2 auth callback, secrets_masker
subclass compat shim, and two provider unit tests — fixed by binding
the loop-derived variable as a default argument on the inner function
or lambda.
(cherry picked from commit af0a377)
Co-authored-by: Deepak kumar <deepakkumar@meta.com>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
@boring-cyborgboring-cyborgBot added provider:google Google (including GCP) related issues provider:smtp provider:standard labels Aug 29, 2026
@potiuk
potiuk marked this pull request as ready for review August 29, 2026 23:48
@potiuk
potiuk merged commit 35dd6f8 into v3-3-testAug 29, 2026
18 of 25 checks passed
@potiuk
potiuk deleted the backport-af0a377-v3-3-test branch August 29, 2026 23:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@potiuk@dkranchii