Scrapy, a fast high-level web crawling & scraping framework for Python.
Add ruff with basic rules. (#6565)
Andrey Rakhmatullincc146b9df7c6
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex b411f4927..ec8693c00 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -1,4 +1,8 @@repos:+- repo: https://github.com/astral-sh/ruff-pre-commit+ rev: v0.8.1+ hooks:+ - id: ruff- repo: https://github.com/PyCQA/banditrev: 1.7.9hooks:diff --git a/pyproject.toml b/pyproject.tomlindex f25715e76..b6c02472d 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -232,4 +232,25 @@ markers = ["requires_botocore: marks tests that need botocore (but not boto3)","requires_boto3: marks tests that need botocore and boto3",]-filterwarnings = []\ No newline at end of file+filterwarnings = []++[tool.ruff.lint]+extend-select = [+]+ignore = [+]++[tool.ruff.lint.per-file-ignores]+# Exclude files that are meant to provide top-level imports+"scrapy/__init__.py" = ["E402"]+"scrapy/core/downloader/handlers/http.py" = ["F401"]+"scrapy/http/__init__.py" = ["F401"]+"scrapy/linkextractors/__init__.py" = ["E402", "F401"]+"scrapy/selector/__init__.py" = ["F401"]+"scrapy/spiders/__init__.py" = ["E402", "F401"]++# Issues pending a review:+"docs/conf.py" = ["E402"]+"scrapy/utils/url.py" = ["F403", "F405"]+"tests/CrawlerRunner/change_reactor.py" = ["E402"]+"tests/test_loader.py" = ["E741"]diff --git a/scrapy/http/request/form.py b/scrapy/http/request/form.pyindex 10ad1305e..b3c3d7c7a 100644--- a/scrapy/http/request/form.py+++ b/scrapy/http/request/form.py@@ -186,7 +186,7 @@ def _get_inputs(if not dont_click:clickable = _get_clickable(clickdata, form)- if clickable and clickable[0] not in formdata and not clickable[0] is None:+ if clickable and clickable[0] not in formdata and clickable[0] is not None:values.append(clickable)formdata_items = formdata.items() if isinstance(formdata, dict) else formdatadiff --git a/tests/test_pipeline_crawl.py b/tests/test_pipeline_crawl.pyindex 7add27aa7..9e1b1ab5b 100644--- a/tests/test_pipeline_crawl.py+++ b/tests/test_pipeline_crawl.py@@ -218,7 +218,7 @@ class FileDownloadCrawlTestCase(TestCase):skip_pillow: str | Nonetry:- from PIL import Image # noqa: imported just to check for the import error+ from PIL import Image # noqa: F401except ImportError:skip_pillow = "Missing Python Imaging Library, install https://pypi.org/pypi/Pillow"else:diff --git a/tests/test_pipeline_media.py b/tests/test_pipeline_media.pyindex cb1e2f9a1..dd8f1084a 100644--- a/tests/test_pipeline_media.py+++ b/tests/test_pipeline_media.py@@ -19,7 +19,7 @@ from scrapy.utils.signal import disconnect_allfrom scrapy.utils.test import get_crawlertry:- from PIL import Image # noqa: imported just to check for the import error+ from PIL import Image # noqa: F401except ImportError:skip_pillow: str | None = ("Missing Python Imaging Library, install https://pypi.org/pypi/Pillow"