From 7b33931df2982bd35e0cdb38d0a1e1d77d34ce47 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 17 Apr 2023 10:21:20 -0400 Subject: [PATCH] Replace flake8 with ruff. --- .gitignore | 2 ++ .ruff.toml | 12 ++++++++++++ setup.cfg | 3 +++ setup.py | 3 +-- tox.ini | 7 +------ 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .ruff.toml diff --git a/.gitignore b/.gitignore index 7c7fa2afd..0cf688c54 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,5 @@ zope.interface-*.egg # This is the plaintext of the private environment needed for some CircleCI # operations. It's never supposed to be checked in. secret-env-plain + +.ruff_cache \ No newline at end of file diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000..75ff62c2d --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,12 @@ +select = [ + # Pyflakes checks + "F", + # Prohibit tabs: + "W191", + # No trailing whitespace: + "W291", + "W293", + # Make sure we bind closure variables in a loop (equivalent to pylint + # cell-var-from-loop): + "B023", +] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index f4539279e..9415b3ab4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,6 +6,9 @@ develop = update_version develop bdist_egg = update_version bdist_egg bdist_wheel = update_version bdist_wheel +# This has been replaced by ruff (see .ruff.toml), which has same checks as +# flake8 plus many more, and is also faster. However, we're keeping this config +# in case people still use flake8 in IDEs, etc.. [flake8] # Enforce all pyflakes constraints, and also prohibit tabs for indentation. # Reference: diff --git a/setup.py b/setup.py index 854a333f1..3358aa6c6 100644 --- a/setup.py +++ b/setup.py @@ -399,12 +399,11 @@ setup(name="tahoe-lafs", # also set in __init__.py "gpg", ], "test": [ - "flake8", # Pin a specific pyflakes so we don't have different folks # disagreeing on what is or is not a lint issue. We can bump # this version from time to time, but we will do it # intentionally. - "pyflakes == 3.0.1", + "ruff==0.0.261", "coverage ~= 5.0", "mock", "tox ~= 3.0", diff --git a/tox.ini b/tox.ini index a191d6078..2daf8dca3 100644 --- a/tox.ini +++ b/tox.ini @@ -108,14 +108,9 @@ setenv = # entire codebase, including various pieces of supporting code. DEFAULT_FILES=src integration static misc setup.py commands = - flake8 {posargs:{env:DEFAULT_FILES}} + ruff check {posargs:{env:DEFAULT_FILES}} python misc/coding_tools/check-umids.py {posargs:{env:DEFAULT_FILES}} python misc/coding_tools/check-debugging.py {posargs:{env:DEFAULT_FILES}} - # B023: Find loop variables that aren't bound in a loop, equivalent of pylint - # cell-var-from-loop. - # W291,W293: Trailing whitespace. - # ruff could probably replace flake8 and perhaps above tools as well... - ruff check --select=B023,W291,W293 {posargs:{env:DEFAULT_FILES}} # If towncrier.check fails, you forgot to add a towncrier news # fragment explaining the change in this branch. Create one at