Skip to content

Commit 875b381

Browse files
committed
flake8
1 parent 61c669b commit 875b381

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/ps_helper/middlewares/proxy_rotator.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,15 @@ def log_summary(self, spider):
5454
fails = stats["fails"]
5555
success = stats["success"]
5656
rate = (success / total * 100) if total else 0
57-
banned = (
58-
"YES" if stats.get("banned_until", 0) > time.time() else "NO"
59-
)
57+
banned = "YES" if stats.get("banned_until", 0) > time.time() else "NO"
6058
spider.logger.info(
6159
f"Proxy: {proxy}\n"
6260
f" Total requests: {total}\n"
6361
f" Successes: {success}\n"
6462
f" Failures: {fails}\n"
6563
f" Success rate: {rate:.1f}%\n"
6664
f" Banned: {banned}\n"
67-
f"{'-'*50}"
65+
f"{'-' * 50}"
6866
)
6967
logger.info("=" * 60)
7068

@@ -149,7 +147,13 @@ class SmartProxyRotatorMiddleware(BaseProxyRotator):
149147
* ``PROXY_ROTATION_MODE`` - 'random' or 'round_robin'
150148
"""
151149

152-
def __init__(self, proxy_providers, ban_threshold=3, cooldown_time=300, rotation_mode="random"):
150+
def __init__(
151+
self,
152+
proxy_providers,
153+
ban_threshold=3,
154+
cooldown_time=300,
155+
rotation_mode="random",
156+
):
153157
super().__init__(proxy_providers)
154158
self.ban_threshold = ban_threshold
155159
self.cooldown_time = cooldown_time
@@ -234,4 +238,4 @@ def process_exception(self, request, exception, spider):
234238
return None
235239

236240
def spider_closed(self, spider):
237-
self.log_summary(spider)
241+
self.log_summary(spider)

tests/test_proxy_middlewares.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
22
import time
3-
from types import SimpleNamespace
43
from scrapy.http import Request, Response
54
from scrapy.spiders import Spider
65

0 commit comments

Comments
 (0)