@@ -11,6 +11,71 @@ Most of the tools presented can be configured using :ref:`the
11
11
\`\` pyproject.toml\`\` file`. Avoiding dotfiles leads to a much
12
12
cleaner root project directory.
13
13
14
+ Ruff
15
+ ----
16
+
17
+ | `Ruff`_ is a Python linter and code formatter written in Rust.
18
+ | It aims to be orders of magnitude faster than alternative tools while integrating more
19
+ functionality behind a single, common interface.
20
+ | Ruff can be used to replace linters and formatters like ``Flake8`` (natively re-implementing
21
+ its popular plugins), ``Black`` and ``isort``: It provides drop-in parity with these tools,
22
+ while executing tens or hundreds of times faster. It is actively developed and used in major
23
+ open-source projects.
24
+ | In addition, it offers the following features and advantages:
25
+
26
+ - Installable via ``pip ``
27
+
28
+ - ``pyproject.toml `` support
29
+
30
+ - Python 3.7 to 3.13 compatibility
31
+
32
+ - Built-in caching, to avoid re-analyzing unchanged files
33
+
34
+ - Over 800 built-in rules
35
+
36
+ - Editor integrations for VS Code or PyCharm
37
+
38
+ A minimum Ruff configuration for a PyAnsys project (to be included in the ``pyproject.toml ``)
39
+ may look like this:
40
+
41
+ .. code-block :: toml
42
+
43
+ [tool.ruff]
44
+ line-length = 100
45
+ fix = true
46
+
47
+ [tool.ruff.format]
48
+ quote-style = "double"
49
+ indent-style = "space"
50
+
51
+ [tool.ruff.lint]
52
+ select = [
53
+ "E", # pycodestyle, see https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
54
+ "D", # pydocstyle, see https://docs.astral.sh/ruff/rules/#pydocstyle-d
55
+ "F", # pyflakes, see https://docs.astral.sh/ruff/rules/#pyflakes-f
56
+ "I", # isort, see https://docs.astral.sh/ruff/rules/#isort-i
57
+ "N", # pep8-naming, see https://docs.astral.sh/ruff/rules/#pep8-naming-n
58
+ "PTH", # flake8-use-pathlib, https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
59
+ "TD", # flake8-todos, https://docs.astral.sh/ruff/rules/#flake8-todos-td
60
+ ]
61
+ ignore = [
62
+ "rule_to_ignore", # list all rules that shall be ignored by the linter
63
+ ]
64
+
65
+ [tool.ruff.lint.pydocstyle]
66
+ convention = "numpy"
67
+
68
+ [tool.ruff.lint.isort]
69
+ combine-as-imports = true
70
+ force-sort-within-sections = true
71
+
72
+ | When migrating a project to Ruff, linting and formatting rules shall be added step by step,
73
+ gradually resolving the triggered errors.
74
+ | For more information about configuring Ruff, as well as a complete description of the available
75
+ rules and settings, please refer to the `tool's documentation
76
+ <https://docs.astral.sh/ruff/configuration/>`__.
77
+
78
+
14
79
Black
15
80
-----
16
81
0 commit comments