From 9a74399792c5cd0b711e245c4dfbbe239be2b4c2 Mon Sep 17 00:00:00 2001 From: tanishqtayade Date: Mon, 22 Jun 2026 17:03:56 +0530 Subject: [PATCH] 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. --- scrapy/utils/signal.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scrapy/utils/signal.py b/scrapy/utils/signal.py index ee391a49e..b43aa8551 100644 --- a/scrapy/utils/signal.py +++ b/scrapy/utils/signal.py @@ -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)