Skip to content

Commit d002d37

Browse files
docs: Harmonising documentation with changes made to code style tool page
1 parent ac58e48 commit d002d37

File tree

4 files changed

+52
-61
lines changed

4 files changed

+52
-61
lines changed

doc/source/coding-style/formatting-tools.rst

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,11 @@ configuration that includes both code and documentation formatting tools.
127127
128128
repos:
129129
130-
- repo: https://github.com/psf/black
131-
rev: X.Y.Z
132-
hooks:
133-
- id: black
134-
135-
- repo: https://github.com/pycqa/isort
136-
rev: X.Y.Z
137-
hooks:
138-
- id: isort
139-
140-
- repo: https://github.com/PyCQA/flake8
141-
rev: X.Y.Z
130+
- repo: https://github.com/astral-sh/ruff-pre-commit
131+
rev: vX.Y.Z
142132
hooks:
143-
- id: flake8
133+
- id: ruff
134+
- id: ruff-format
144135
145136
- repo: https://github.com/codespell-project/codespell
146137
rev: vX.Y.Z

doc/source/coding-style/required-standard.rst

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,35 @@ Required ``pyproject.toml`` file configuration
1313

1414
.. code-block:: toml
1515
16-
[tool.black]
17-
line-length = "<length>"
18-
19-
[tool.isort]
20-
profile = "black"
21-
force_sort_within_sections = true
22-
line_length = "<length>"
23-
src_paths = ["doc", "src", "tests"]
16+
[tool.ruff]
17+
line-length = 100
18+
fix = true
19+
20+
[tool.ruff.format]
21+
quote-style = "double"
22+
indent-style = "space"
23+
24+
[tool.ruff.lint]
25+
select = [
26+
"E", # pycodestyle, see https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
27+
"D", # pydocstyle, see https://docs.astral.sh/ruff/rules/#pydocstyle-d
28+
"F", # pyflakes, see https://docs.astral.sh/ruff/rules/#pyflakes-f
29+
"I", # isort, see https://docs.astral.sh/ruff/rules/#isort-i
30+
"N", # pep8-naming, see https://docs.astral.sh/ruff/rules/#pep8-naming-n
31+
"PTH", # flake8-use-pathlib, https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
32+
"TD", # flake8-todos, https://docs.astral.sh/ruff/rules/#flake8-todos-td
33+
]
34+
ignore = [
35+
"TD003", # Missing issue link in TODOs comment
36+
]
37+
38+
[tool.ruff.lint.pydocstyle]
39+
convention = "numpy"
2440
41+
[tool.ruff.lint.isort]
42+
combine-as-imports = true
43+
force-sort-within-sections = true
44+
2545
[tool.coverage.run]
2646
source = ["ansys.<product>"]
2747
@@ -34,17 +54,6 @@ Required ``pyproject.toml`` file configuration
3454
[tool.pydocstyle]
3555
convention = "numpy"
3656
37-
Required flake8 configuration
38-
-----------------------------
39-
40-
The following ``.flake8`` file is also required:
41-
42-
.. code-block:: toml
43-
44-
[flake8]
45-
max-line-length = 88
46-
extend-ignore = 'E203'
47-
4857
Required ``pre-commit`` configuration
4958
-------------------------------------
5059

@@ -54,22 +63,13 @@ You can take advantage of `pre-commit`_ by including a
5463
.. code-block:: yaml
5564
5665
repos:
57-
58-
- repo: https://github.com/psf/black
59-
rev: X.Y.Z
60-
hooks:
61-
- id: black
62-
63-
- repo: https://github.com/pycqa/isort
64-
rev: X.Y.Z
65-
hooks:
66-
- id: isort
6766
68-
- repo: https://github.com/PyCQA/flake8
69-
rev: X.Y.Z
67+
- repo: https://github.com/astral-sh/ruff-pre-commit
68+
rev: vX.Y.Z
7069
hooks:
71-
- id: flake8
72-
70+
- id: ruff
71+
- id: ruff-format
72+
7373
- repo: https://github.com/codespell-project/codespell
7474
rev: vX.Y.Z
7575
hooks:

doc/source/content-writing/content-how-tos/create-PR.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Run pre-commit locally
2828

2929
`pre-commit <pre-commit_>`_ is a tool for ensuring that all the changes that you make to
3030
files in your project successfully pass all checks run by the code style tools that are
31-
configured as part of the CI/CD process. These tools, which typically include `Black <Black_>`_,
32-
`isort <isort_>`_, and `Flake8 <Flake8_>`_, analyze, format, review, and improve
33-
code quality and security. For more information on the code style tools most commonly
34-
configured for use in PyAnsys projects, see :ref:`code_style_tools`.
31+
configured as part of the CI/CD process. These tools, which typically include `Ruff`_,
32+
analyze, format, review, and improve code quality and security. For more information on
33+
the code style tools most commonly configured for use in PyAnsys projects,
34+
see :ref:`code_style_tools`.
3535

3636
Because you do not want the **Code style** check for your PyAnsys project to fail
3737
when you create or push changes to a PR, you want to periodically run ``pre-commit``

doc/source/content-writing/content-how-tos/resolve-issues-causing-check-failures.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ Actions that you might take include these:
9999
Resolve too long line lengths and broken links
100100
----------------------------------------------
101101

102-
In PyAnsys projects, `Flake8 <Flake8_>`_ is a code style tool in the CI/CD process
103-
that checks the quality of the Python code. When you run ``pre-commit`` locally,
104-
Flake8 is one of the tools that it is configured to run. If Flake8 finds a line in a
105-
Python file that is too long, it raises an error. Providing that this line is a
106-
docstring or message string, you can manually change it in the PY file.
102+
In PyAnsys projects, `Ruff`_ is a code style tool in the CI/CD process that checks the
103+
quality of the Python code. When you run ``pre-commit`` locally, Ruff is one of the tools
104+
that it is configured to run. If Ruff finds a line in a Python file that is too long,
105+
it raises an error. Providing that this line is a docstring or message string, you can
106+
manually change it in the PY file.
107107

108108
Sometimes, however, the line that is too long is for a URL added to the ``linkcheck_ignore``
109109
variable in the Sphinx configuration (``doc/source/conf.py``) file. Here is an example of how
@@ -150,23 +150,23 @@ Here is what adding these lines looks like:
150150
"38-comments-and-docstrings",
151151
]
152152
153-
If you committed the preceding changes, Sphinx would no longer find any broken links. However, Flake8
153+
If you committed the preceding changes, Sphinx would no longer find any broken links. However, Ruff
154154
would throw line length errors for the two lines that define the items for the ``linkcheck_ignore`` variable
155155
in the Sphinx :file:`config.py` file. Because you cannot modify the length of these lines, you must follow
156-
each of these URLs (and any comment about it) with a space and then ``# noqa: 501``.
156+
each of these URLs (and any comment about it) with a space and then ``# noqa: E501``.
157157

158-
You can scroll to the end of these lines to see how they now conclude with ``# noqa: 501``:
158+
You can scroll to the end of these lines to see how they now conclude with ``# noqa: E501``:
159159

160160
.. code::
161161
162162
# Linkcheck ignore too long lines
163163
164164
linkcheck_ignore = [
165-
"https://myapps.microsoft.com/signin/8f67c59b-83ac-4318-ae96-f0588382ddc0?tenantId=34c6ce67-15b8-4eff-80e9-52da8be89706", # Join Ansys GitHub account # noqa: 501
166-
"https://myapps.microsoft.com/signin/42c0fa04-03f2-4407-865e-103af6973dae?tenantId=34c6ce67-15b8-4eff-80e9-52da8be89706", # Join Ansys internal GitHub account # noqa: 501
165+
"https://myapps.microsoft.com/signin/8f67c59b-83ac-4318-ae96-f0588382ddc0?tenantId=34c6ce67-15b8-4eff-80e9-52da8be89706", # Join Ansys GitHub account # noqa: E501
166+
"https://myapps.microsoft.com/signin/42c0fa04-03f2-4407-865e-103af6973dae?tenantId=34c6ce67-15b8-4eff-80e9-52da8be89706", # Join Ansys internal GitHub account # noqa: E501
167167
]
168168
169-
When you commit these changes, Flake sees the ``# noqa: 501`` comments at the end of these lines
169+
When you commit these changes, Ruff sees the ``# noqa: E501`` comments at the end of these lines
170170
and knows to ignore their long line lengths.
171171

172172
.. _resolve_mismatched_message_strings:

0 commit comments

Comments
 (0)