2
2
3
3
Style Guide Enforcement
4
4
=======================
5
- This topic describes the use of `Flake8 `_ for `PEP8 `_ style
5
+ This topic describes the use of `flake8 `_ for `PEP 8 `_ style
6
6
enforcement and the minimum standards expected. PyAnsys libraries
7
7
are expected to be consistent with these guidelines.
8
8
9
- .. _PEP8 : https://www.python.org/dev/peps/pep-0008/
10
-
11
9
Flake8
12
10
~~~~~~
13
11
`Flake8 `_ is a Python tool for enforcing code styling. It is a wrapper
@@ -16,12 +14,6 @@ around the following three tools: `PyFlakes`_, `pycodestyle`_, and
16
14
checking the code against a variety of style rules, such as line length,
17
15
code complexity, and whitespace.
18
16
19
- .. _Flake8 : https://flake8.pycqa.org/en/latest/index.html
20
- .. _PyFlakes : https://pypi.org/project/pyflakes/
21
- .. _pycodestyle : https://pypi.org/project/pycodestyle/
22
- .. _`Ned Batchelder's McCabe script for complexity` : https://github.com/PyCQA/mccabe
23
- .. _configuring-flake8 :
24
-
25
17
Configuring Flake8
26
18
------------------
27
19
Flake8 supports configuring a specific set of style rules to
@@ -70,7 +62,7 @@ The example configuration defines the following options:
70
62
71
63
- ``max-line-length ``
72
64
Denotes the maximum line length for any one line of code.
73
- The `PEP8 `_ standard advises a maximum line length of 79. Because
65
+ The `PEP 8 `_ standard advises a maximum line length of 79. Because
74
66
this is a bit limiting in some cases, the maximum line length
75
67
recommended for a PyAnsys library is 100.
76
68
@@ -106,25 +98,22 @@ base.
106
98
Utilizing Black
107
99
~~~~~~~~~~~~~~~
108
100
Manually checking for code styling can be a tedious task. Luckily,
109
- several Python tools for auto-formatting code to meet PEP8 standards
101
+ several Python tools for auto-formatting code to meet ` PEP 8 `_ standards
110
102
are available to help with this. The PyAnsys project suggests the use of the
111
103
the formatting tool `black `_.
112
104
113
105
On completing a code change, and before committing, `black `_ can be
114
- run to reformat the code, following the PEP8 guidelines enforced through
115
- Flake8 . This will limit any manual code changes needed to address style
106
+ run to reformat the code, following the ` PEP 8 `_ guidelines enforced through
107
+ ` flake8 `_ . This will limit any manual code changes needed to address style
116
108
rules.
117
109
118
- .. _black : https://black.readthedocs.io/en/stable/
119
110
120
111
Optionally, it is possible to automate the use of `black `_. This can be
121
112
done with the tool `pre-commit `_. Setting up a `pre-commit hook
122
113
to run black <https://black.readthedocs.io/en/stable/integrations/source_version_control.html> `_
123
114
will automatically format the code before committing. This simple way of
124
115
incorporating code style checks into the development workflow to maintain
125
- PEP8 guidelines requires minimal manual effort.
126
-
127
- .. _pre-commit : https://pre-commit.com/
116
+ `PEP 8 `_ guidelines requires minimal manual effort.
128
117
129
118
130
119
Minimum Standards
@@ -232,21 +221,4 @@ Your ``.flake8`` file should be:
232
221
max-line-length = 100
233
222
statistics = True
234
223
235
-
236
- .. _W191 : https://www.flake8rules.com/rules/W191.html
237
- .. _W291 : https://www.flake8rules.com/rules/W291.html
238
- .. _W293 : https://www.flake8rules.com/rules/W293.html
239
- .. _W391 : https://www.flake8rules.com/rules/W391.html
240
- .. _E115 : https://www.flake8rules.com/rules/E115.html
241
- .. _E117 : https://www.flake8rules.com/rules/E117.html
242
- .. _E122 : https://www.flake8rules.com/rules/E122.html
243
- .. _E124 : https://www.flake8rules.com/rules/E124.html
244
- .. _E125 : https://www.flake8rules.com/rules/E125.html
245
- .. _E225 : https://www.flake8rules.com/rules/E225.html
246
- .. _E231 : https://www.flake8rules.com/rules/E231.html
247
- .. _E301 : https://www.flake8rules.com/rules/E301.html
248
- .. _E303 : https://www.flake8rules.com/rules/E303.html
249
- .. _E501 : https://www.flake8rules.com/rules/E501.html
250
- .. _F401 : https://www.flake8rules.com/rules/F401.html
251
- .. _F403 : https://www.flake8rules.com/rules/F403.html
252
-
224
+ .. include :: ../links.rst
0 commit comments