diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b95b32d7ddb..1f670f2bec3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,27 +65,15 @@ repos: .*/loan_write_off.js )$ - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.0 hooks: - - id: flake8 - additional_dependencies: [ - 'flake8-bugbear', - ] - args: ['--config', '.github/helper/.flake8_strict'] - exclude: ".*setup.py$" + - id: ruff + name: "Run ruff linter and apply fixes" + args: ["--fix"] - - repo: https://github.com/adityahase/black - rev: 9cb0a69f4d0030cdf687eddf314468b39ed54119 - hooks: - - id: black - additional_dependencies: ['click==8.0.4'] - - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - exclude: ".*setup.py$" + - id: ruff-format + name: "Format Python code" ci: diff --git a/pyproject.toml b/pyproject.toml index 7f28903f120..af0fbffd9ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,17 +32,41 @@ build-backend = "flit_core.buildapi" [tool.bench.dev-dependencies] hypothesis = "~=6.31.0" -[tool.black] -line-length = 99 - -[tool.isort] -line_length = 99 -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -indent = "\t" - [tool.bench.frappe-dependencies] frappe = ">=14.0.0,<15.0.0" + +[tool.ruff] +line-length = 110 +target-version = "py310" + +[tool.ruff.lint] +select = [ + "F", + "E", + "W", + "I", + "UP", + "B", + "RUF", +] +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 + "W191", # indentation contains tabs + "RUF001", # string contains ambiguous unicode character +] + +[tool.ruff.format] +quote-style = "double" +indent-style = "tab" +docstring-code-format = true