diff --git a/pyproject.toml b/pyproject.toml index 065382205..a0b37b966 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -222,6 +222,8 @@ extend-select = [ "D", # flake8-future-annotations "FA", + # flynt + "FLY", # refurb "FURB", # isort diff --git a/scrapy/pqueues.py b/scrapy/pqueues.py index 5b2f81335..a04e0107b 100644 --- a/scrapy/pqueues.py +++ b/scrapy/pqueues.py @@ -34,7 +34,7 @@ def _path_safe(text: str) -> str: # as we replace some letters we can get collision for different slots # add we add unique part unique_slot = hashlib.md5(text.encode("utf8")).hexdigest() # noqa: S324 - return "-".join([pathable_slot, unique_slot]) + return f"{pathable_slot}-{unique_slot}" class QueueProtocol(Protocol): diff --git a/tests/test_spidermiddleware_referer.py b/tests/test_spidermiddleware_referer.py index 23b0c17c6..cefd33e4e 100644 --- a/tests/test_spidermiddleware_referer.py +++ b/tests/test_spidermiddleware_referer.py @@ -891,14 +891,7 @@ class TestSettingsPolicyByName(TestCase): # test parsing without space(s) after the comma settings1 = Settings( { - "REFERRER_POLICY": ",".join( - [ - "some-custom-unknown-policy", - POLICY_SAME_ORIGIN, - POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN, - "another-custom-unknown-policy", - ] - ) + "REFERRER_POLICY": f"some-custom-unknown-policy,{POLICY_SAME_ORIGIN},{POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN},another-custom-unknown-policy" } ) mw1 = RefererMiddleware(settings1) @@ -907,13 +900,7 @@ class TestSettingsPolicyByName(TestCase): # test parsing with space(s) after the comma settings2 = Settings( { - "REFERRER_POLICY": ", ".join( - [ - POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN, - "another-custom-unknown-policy", - POLICY_UNSAFE_URL, - ] - ) + "REFERRER_POLICY": f"{POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN}, another-custom-unknown-policy, {POLICY_UNSAFE_URL}" } ) mw2 = RefererMiddleware(settings2) @@ -922,13 +909,7 @@ class TestSettingsPolicyByName(TestCase): def test_multiple_policy_tokens_all_invalid(self): settings = Settings( { - "REFERRER_POLICY": ",".join( - [ - "some-custom-unknown-policy", - "another-custom-unknown-policy", - "yet-another-custom-unknown-policy", - ] - ) + "REFERRER_POLICY": "some-custom-unknown-policy,another-custom-unknown-policy,yet-another-custom-unknown-policy" } ) with self.assertRaises(RuntimeError):