From fbb0e4479107e15639941acaafc2a5f2b984a01b Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Mon, 5 Feb 2024 18:32:12 +0530 Subject: [PATCH] ci: switch to ruff for linting Signed-off-by: Akhil Narang --- .flake8 | 75 ----------------------------------------- .pre-commit-config.yaml | 16 ++------- pyproject.toml | 42 +++++++++++++++++++---- 3 files changed, 37 insertions(+), 96 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index e783fbbeb3..0000000000 --- a/.flake8 +++ /dev/null @@ -1,75 +0,0 @@ -[flake8] -ignore = - B001, - B007, - B009, - B010, - B950, - E101, - E111, - E114, - E116, - E117, - E121, - E122, - E123, - E124, - E125, - E126, - E127, - E128, - E131, - E201, - E202, - E203, - E211, - E221, - E222, - E223, - E224, - E225, - E226, - E228, - E231, - E241, - E242, - E251, - E261, - E262, - E265, - E266, - E271, - E272, - E273, - E274, - E301, - E302, - E303, - E305, - E306, - E402, - E501, - E502, - E701, - E702, - E703, - E741, - F401, - F403, - F405, - W191, - W291, - W292, - W293, - W391, - W503, - W504, - E711, - E129, - F841, - E713, - E712, - B028, - -max-line-length = 200 -exclude=,test_*.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e9e2adb90..bc20e86eba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,18 +20,12 @@ repos: - id: check-yaml - id: debug-statements - - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 - hooks: - - id: pyupgrade - args: ['--py310-plus'] - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.2.0 hooks: - id: ruff - name: "Sort Python imports" - args: ["--select", "I", "--fix"] + name: "Run ruff linter and apply fixes" + args: ["--fix"] - id: ruff-format name: "Format Python code" @@ -72,12 +66,6 @@ repos: frappe/public/js/lib/.* )$ - - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - additional_dependencies: ['flake8-bugbear',] - ci: autoupdate_schedule: weekly skip: [] diff --git a/pyproject.toml b/pyproject.toml index c19d666a59..82b0c8c726 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,13 +88,6 @@ dependencies = [ requires = ["flit_core >=3.4,<4"] build-backend = "flit_core.buildapi" -[tool.ruff] -line-length = 110 - -[tool.ruff.format] -indent-style = "tab" -docstring-code-format = true - [tool.bench.dev-dependencies] coverage = "~=6.5.0" Faker = "~=18.10.1" @@ -104,3 +97,38 @@ watchdog = "~=3.0.0" hypothesis = "~=6.77.0" responses = "==0.23.1" freezegun = "~=1.2.2" + +[tool.ruff] +line-length = 110 +target-version = "py310" + +[tool.ruff.lint] +select = [ + "F", + "E", + "W", + "I", + "UP", + "B", +] +ignore = [ + "B017", # assertRaises(Exception) - should be more specific + "B018", # useless expression, not assigned to anything + "B023", # function doesn't bind loop variable - will have last iteration's value + "B904", # raise inside except without from + "E101", # indentation contains mixed spaces and tabs + "E402", # module level import not at top of file + "E501", # line too long + "E741", # ambiguous variable name + "F401", # "unused" imports + "F403", # can't detect undefined names from * import + "F405", # can't detect undefined names from * import + "F722", # syntax error in forward type annotation + "F821", # undefined name + "W191", # indentation contains tabs +] + +[tool.ruff.format] +quote-style = "double" +indent-style = "tab" +docstring-code-format = true