Skip to content

Commit ec57770

Browse files
committed
Add ruff settings to cookiecutter template & update documentation
1 parent e9c106c commit ec57770

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

doc/user_guide/features/formatting_code/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ For autoformatting, the following tools are used:
2727
packages, third party packages, and local application imports).
2828
* `pyupgrade <https://pypi.org/project/pyupgrade/>`__ - upgrades syntax for newer
2929
versions of the Python language.
30+
* `ruff <https://docs.astral.sh/ruff/>`__ - checks and fixes code per its configuration.
31+
Currently, the PTB only supports removing unused imports.
3032

3133
In the PTB, these tools are bundled into nox sessions to ensure that they are run in a
3234
deterministic manner.
@@ -81,3 +83,16 @@ and is defined in the :meth:`exasol.toolbox.config.BaseConfig.pyupgrade_argument
8183

8284
For further configuration options, see the
8385
`pyupgrade documentation <https://pypi.org/project/pyupgrade/>`__.
86+
87+
ruff
88+
^^^^
89+
90+
Ensure ``ruff`` is configured like so:
91+
92+
.. literalinclude:: ../../../../project-template/{{cookiecutter.repo_name}}/pyproject.toml
93+
:language: toml
94+
:start-at: [tool.ruff]
95+
:end-before: [tool.mypy.overrides]
96+
97+
For further configuration options, see
98+
`ruff options <https://docs.astral.sh/ruff/configuration>`__.

doc/user_guide/features/formatting_code/troubleshooting.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ might want to ignore automatically applied formatting.
3838
| | | |
3939
| | <line-to-ignore> # isort:skip| # isort:skip_file |
4040
+-----------------------+--------------------------------+-----------------------+
41+
| formatting from ruff | .. code-block:: python | .. code-block:: python|
42+
| | | |
43+
| | <line-to-ignore> # noqa: F401| # ruff: noqa F401 |
44+
+-----------------------+--------------------------------+-----------------------+
4145

4246

4347
In the ``checks.yml``, ``project:format`` wants me to reformat code I did not modify

project-template/{{cookiecutter.repo_name}}/pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ ignore = []
5757
max-line-length = 88
5858
max-module-lines = 800
5959

60+
[tool.ruff.lint]
61+
extend-ignore = [
62+
"E", # Syntax errors
63+
"F", # Pyflakes rules (excluding F401)
64+
"UP", # pyupgrade rules
65+
"D", # Docstring rules
66+
]
67+
extend-select = ["F401"]
68+
unfixable = []
69+
6070
[[tool.mypy.overrides]]
6171
module = [
6272
"test.*",

0 commit comments

Comments
 (0)