Fix cell-var-from-loop in _send_catch_log_deferred

Replace lambda capturing receiver by reference with a default
argument to capture it by value, fixing a potential bug where
all deferred callbacks could reference the last receiver in the
loop instead of their respective receivers.

Removes the pylint disable comment and TODO that were suppressing
this issue.
This commit is contained in:
tanishqtayade 2026-06-22 17:03:56 +05:30
parent 75f05d4e80
commit 9a74399792
1 changed files with 1 additions and 5 deletions

View File

@ -125,12 +125,8 @@ def _send_catch_log_deferred(
**named,
)
d.addErrback(logerror, receiver)
# TODO https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/cell-var-from-loop.html
d2: Deferred[tuple[TypingAny, TypingAny]] = d.addBoth(
lambda result: (
receiver, # pylint: disable=cell-var-from-loop # noqa: B023
result,
)
lambda result, recv=receiver: (recv, result)
)
dfds.append(d2)