Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Replace isort with the ruff isort rules.

Andrey Rakhmatullincc484efd43b0
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 39b9a33aa..d253f61c6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -8,10 +8,6 @@ repos:
rev: 24.4.2
hooks:
- id: black
-- repo: https://github.com/pycqa/isort
- rev: 5.13.2
- hooks:
- - id: isort
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
diff --git a/pyproject.toml b/pyproject.toml
index 7dc1f6ec3..a2dabcf4b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -116,9 +116,6 @@ disable_warnings = ["include-ignored"]
# https://github.com/nedbat/coveragepy/issues/831#issuecomment-517778185
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
-[tool.isort]
-profile = "black"
-
[tool.pylint.MASTER]
persistent = "no"
jobs = 1 # >1 hides results
@@ -226,6 +223,8 @@ extend-select = [
"FA",
# refurb
"FURB",
+ # isort
+ "I",
# flake8-implicit-str-concat
"ISC",
# flake8-logging
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.py
index bd3200e9f..9f65794fe 100644
--- a/scrapy/core/downloader/handlers/http11.py
+++ b/scrapy/core/downloader/handlers/http11.py
@@ -17,9 +17,14 @@ from twisted.internet.endpoints import TCP4ClientEndpoint
from twisted.internet.error import TimeoutError
from twisted.internet.protocol import Factory, Protocol, connectionDone
from twisted.python.failure import Failure
-from twisted.web.client import URI, Agent, HTTPConnectionPool
+from twisted.web.client import (
+ URI,
+ Agent,
+ HTTPConnectionPool,
+ ResponseDone,
+ ResponseFailed,
+)
from twisted.web.client import Response as TxResponse
-from twisted.web.client import ResponseDone, ResponseFailed
from twisted.web.http import PotentialDataLoss, _DataLoss
from twisted.web.http_headers import Headers as TxHeaders
from twisted.web.iweb import UNKNOWN_LENGTH, IBodyProducer, IPolicyForHTTPS
diff --git a/scrapy/http/cookies.py b/scrapy/http/cookies.py
index 56941ad51..60322fe6e 100644
--- a/scrapy/http/cookies.py
+++ b/scrapy/http/cookies.py
@@ -2,9 +2,8 @@ from __future__ import annotations
import re
import time
-from http.cookiejar import Cookie
+from http.cookiejar import Cookie, CookiePolicy, DefaultCookiePolicy
from http.cookiejar import CookieJar as _CookieJar
-from http.cookiejar import CookiePolicy, DefaultCookiePolicy
from typing import TYPE_CHECKING, Any, cast
from scrapy.utils.httpobj import urlparse_cached
diff --git a/tests/CrawlerRunner/ip_address.py b/tests/CrawlerRunner/ip_address.py
index 5bf7512bc..2f1bb7713 100644
--- a/tests/CrawlerRunner/ip_address.py
+++ b/tests/CrawlerRunner/ip_address.py
@@ -1,9 +1,8 @@
from urllib.parse import urlparse
from twisted.internet import reactor
-from twisted.names import cache
+from twisted.names import cache, resolve
from twisted.names import hosts as hostsModule
-from twisted.names import resolve
from twisted.names.client import Resolver
from twisted.python.runtime import platform