Skip to content

Commit 8afb779

Browse files
barredterraakhilnarang
authored andcommitted
chore: switch to ruff for python formatting/linting
1 parent 8c7213a commit 8afb779

File tree

2 files changed

+44
-32
lines changed

2 files changed

+44
-32
lines changed

.pre-commit-config.yaml

+7-20
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,15 @@ repos:
5555
erpnext/templates/includes/.*
5656
)$
5757
58-
- repo: https://github.com/PyCQA/flake8
59-
rev: 6.0.0
58+
- repo: https://github.com/astral-sh/ruff-pre-commit
59+
rev: v0.2.0
6060
hooks:
61-
- id: flake8
62-
additional_dependencies: [
63-
'flake8-bugbear',
64-
'flake8-tuple',
65-
]
66-
args: ['--config', '.github/helper/.flake8_strict']
67-
exclude: ".*setup.py$"
61+
- id: ruff
62+
name: "Run ruff linter and apply fixes"
63+
args: ["--fix"]
6864

69-
- repo: https://github.com/adityahase/black
70-
rev: 9cb0a69f4d0030cdf687eddf314468b39ed54119
71-
hooks:
72-
- id: black
73-
additional_dependencies: ['click==8.0.4']
74-
75-
- repo: https://github.com/PyCQA/isort
76-
rev: 5.12.0
77-
hooks:
78-
- id: isort
79-
exclude: ".*setup.py$"
65+
- id: ruff-format
66+
name: "Format Python code"
8067

8168

8269
ci:

pyproject.toml

+37-12
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,42 @@ dependencies = [
2828
requires = ["flit_core >=3.4,<4"]
2929
build-backend = "flit_core.buildapi"
3030

31-
[tool.black]
32-
line-length = 99
33-
34-
[tool.isort]
35-
line_length = 99
36-
multi_line_output = 3
37-
include_trailing_comma = true
38-
force_grid_wrap = 0
39-
use_parentheses = true
40-
ensure_newline_before_comments = true
41-
indent = "\t"
42-
4331
[tool.bench.frappe-dependencies]
4432
frappe = ">=16.0.0-dev,<17.0.0"
33+
34+
[tool.ruff]
35+
line-length = 110
36+
target-version = "py310"
37+
38+
[tool.ruff.lint]
39+
select = [
40+
"F",
41+
"E",
42+
"W",
43+
"I",
44+
"UP",
45+
"B",
46+
"RUF",
47+
]
48+
ignore = [
49+
"B017", # assertRaises(Exception) - should be more specific
50+
"B018", # useless expression, not assigned to anything
51+
"B023", # function doesn't bind loop variable - will have last iteration's value
52+
"B904", # raise inside except without from
53+
"E101", # indentation contains mixed spaces and tabs
54+
"E402", # module level import not at top of file
55+
"E501", # line too long
56+
"E741", # ambiguous variable name
57+
"F401", # "unused" imports
58+
"F403", # can't detect undefined names from * import
59+
"F405", # can't detect undefined names from * import
60+
"F722", # syntax error in forward type annotation
61+
"W191", # indentation contains tabs
62+
"RUF001", # string contains ambiguous unicode character
63+
]
64+
typing-modules = ["frappe.types.DF"]
65+
66+
[tool.ruff.format]
67+
quote-style = "double"
68+
indent-style = "tab"
69+
docstring-code-format = true

0 commit comments

Comments
 (0)