From: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) Date: Mon, 25 Aug 2025 11:38:16 +0000 (+0200) Subject: [3.13] Lint: Create a project-wide ``.ruff.toml`` settings file (GH-133124) (#137670) X-Git-Tag: v3.13.8~152 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f75fc9a780dfb92a8b9a8ef5819d3f6fd10a01f9;p=thirdparty%2FPython%2Fcpython.git [3.13] Lint: Create a project-wide ``.ruff.toml`` settings file (GH-133124) (#137670) Co-authored-by: Alex Waygood Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000000..1c015fa88415 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,12 @@ +# Default settings for Ruff in CPython + +# PYTHON_FOR_REGEN +target-version = "py310" + +# PEP 8 +line-length = 79 + +# Enable automatic fixes by default. +# To override this, use ``fix = false`` in a subdirectory's config file +# or ``--no-fix`` on the command line. +fix = true diff --git a/Doc/.ruff.toml b/Doc/.ruff.toml index 111ce03b91df..3e676e13c3f4 100644 --- a/Doc/.ruff.toml +++ b/Doc/.ruff.toml @@ -1,7 +1,6 @@ +extend = "../.ruff.toml" # Inherit the project-wide settings + target-version = "py312" # Align with the version in oldest_supported_sphinx -fix = true -output-format = "full" -line-length = 79 extend-exclude = [ "includes/*", # Temporary exclusions: diff --git a/Lib/test/.ruff.toml b/Lib/test/.ruff.toml index 218eefe52557..f800dc03dce6 100644 --- a/Lib/test/.ruff.toml +++ b/Lib/test/.ruff.toml @@ -1,5 +1,7 @@ -fix = true +extend = "../../.ruff.toml" # Inherit the project-wide settings + target-version = "py312" + extend-exclude = [ # Excluded (run with the other AC files in its own separate ruff job in pre-commit) "test_clinic.py", diff --git a/Tools/build/.ruff.toml b/Tools/build/.ruff.toml new file mode 100644 index 000000000000..dcbf2936290f --- /dev/null +++ b/Tools/build/.ruff.toml @@ -0,0 +1,41 @@ +extend = "../../.ruff.toml" # Inherit the project-wide settings + +[per-file-target-version] +"deepfreeze.py" = "py311" # requires `code.co_exceptiontable` +"stable_abi.py" = "py311" # requires 'tomllib' + +[format] +preview = true +docstring-code-format = true + +[lint] +select = [ + "C4", # flake8-comprehensions + "E", # pycodestyle + "F", # pyflakes + "I", # isort + "ISC", # flake8-implicit-str-concat + "LOG", # flake8-logging + "PGH", # pygrep-hooks + "PT", # flake8-pytest-style + "PYI", # flake8-pyi + "RUF100", # Ban unused `# noqa` comments + "UP", # pyupgrade + "W", # pycodestyle + "YTT", # flake8-2020 +] +ignore = [ + "E501", # Line too long + "F541", # f-string without any placeholders + "PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple` + "PYI025", # Use `from collections.abc import Set as AbstractSet` + "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` +] + +[lint.per-file-ignores] +"{check_extension_modules,freeze_modules}.py" = [ + "UP031", # Use format specifiers instead of percent format +] +"generate_{re_casefix,sre_constants,token}.py" = [ + "UP031", # Use format specifiers instead of percent format +] diff --git a/Tools/clinic/.ruff.toml b/Tools/clinic/.ruff.toml index c019572d0cb1..5033887df0c1 100644 --- a/Tools/clinic/.ruff.toml +++ b/Tools/clinic/.ruff.toml @@ -1,5 +1,4 @@ -target-version = "py310" -fix = true +extend = "../../.ruff.toml" # Inherit the project-wide settings [lint] select = [