Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the usage of augmented assignment statements #5314

elfring opened this issue Nov 11, 2021 · 1 comment 路 Fixed by #5322

Increase the usage of augmented assignment statements #5314

elfring opened this issue Nov 11, 2021 · 1 comment 路 Fixed by #5322


Copy link

elfring commented Nov 11, 2021

馃憖 Some source code analysis tools can help to find opportunities for improving software components.
馃挱 I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/scrapy/core/downloader/handlers/ b/scrapy/core/downloader/handlers/
index 8a91d4c5..38935667 100644
--- a/scrapy/core/downloader/handlers/
+++ b/scrapy/core/downloader/handlers/
@@ -213,7 +213,7 @@ class TunnelingAgent(Agent):
         # proxy host and port are required for HTTP pool `key`
         # otherwise, same remote host connection request could reuse
         # a cached tunneled connection to a different proxy
-        key = key + self._proxyConf
+        key += self._proxyConf
         return super()._requestWithEndpoint(
diff --git a/scrapy/core/http2/ b/scrapy/core/http2/
index c2a4b702..5c393c02 100644
--- a/scrapy/core/http2/
+++ b/scrapy/core/http2/
@@ -285,8 +285,8 @@ class Stream:
             self._protocol.conn.send_data(self.stream_id, data_chunk, end_stream=False)
-            bytes_to_send_size = bytes_to_send_size - chunk_size
-            self.metadata['remaining_content_length'] = self.metadata['remaining_content_length'] - chunk_size
+            bytes_to_send_size -= chunk_size
+            self.metadata['remaining_content_length'] -= chunk_size
         self.metadata['remaining_content_length'] = max(0, self.metadata['remaining_content_length'])
diff --git a/tests/ b/tests/
index 373b2e49..4d448388 100644
--- a/tests/
+++ b/tests/
@@ -22,7 +22,7 @@ class SignalCatcherSpider(Spider):
         return spider
     def on_request_left(self, request, spider):
-        self.caught_times = self.caught_times + 1
+        self.caught_times += 1
 class TestCatching(TestCase):
Copy link

wRAR commented Nov 12, 2021

Can you please make a pull request with the changes you propose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

3 participants