From 256f2b183f39243dc325992f60e1204ea28d6f38 Mon Sep 17 00:00:00 2001 From: Artemis Git Integration Date: Wed, 19 Nov 2025 14:42:43 +0000 Subject: [PATCH] refactor: replace flake8 with ruff for faster linting --- .pre-commit-config.yaml | 8 +++++--- pyproject.toml | 35 +++++++++++++++++++++++++++++++++++ requirements-dev.txt | 1 + setup.cfg | 7 ------- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a0515cf87..95430fd76c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,9 @@ repos: hooks: - id: pyupgrade args: [--py37-plus] -- repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.4 hooks: - - id: flake8 + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 1b7901e155..f795c77fe2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,41 @@ profile = "black" src_paths = ["src/requests", "test"] honor_noqa = true +[tool.ruff] +# Match black's line length +line-length = 88 + +# Target Python 3.9+ (project minimum version) +target-version = "py39" + +# Enable flake8 equivalent rule sets +select = ["E", "W", "F"] + +# Ignore rules to match existing flake8 configuration: +# E203: whitespace before ':' +# E501: line too long (black handles this) +# W503: line break before binary operator +ignore = ["E203", "E501", "W503"] + +# Exclude patterns +exclude = [ + ".git", + ".ruff_cache", + ".venv", + "__pycache__", + "*.pyc", + "build", + "dist", + "docs", + "ext", +] + +# Per-file ignores migrated from setup.cfg [flake8] +[tool.ruff.per-file-ignores] +"src/requests/__init__.py" = ["E402", "F401"] +"src/requests/compat.py" = ["E402", "F401"] +"tests/compat.py" = ["F401"] + [tool.pytest.ini_options] addopts = "--doctest-modules" doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS" diff --git a/requirements-dev.txt b/requirements-dev.txt index 77fedb9716..649eb50dec 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,3 +5,4 @@ pytest-httpbin==2.1.0 httpbin~=0.10.0 trustme wheel +ruff>=0.1.0 diff --git a/setup.cfg b/setup.cfg index 8d44e0e14b..d38e89f0f6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,10 +8,3 @@ requires-dist = charset_normalizer>=2,<4 idna>=2.5,<4 urllib3>=1.21.1,<3 - -[flake8] -ignore = E203, E501, W503 -per-file-ignores = - src/requests/__init__.py:E402, F401 - src/requests/compat.py:E402, F401 - tests/compat.py:F401