22
33Style Guide Enforcement
44=======================
5- The following sections describe the use of `Flake8 `_ for `PEP8 `_ style
5+ This topic describes the use of `Flake8 `_ for `PEP8 `_ style
66enforcement and the minimum standards expected. PyAnsys libraries
77are expected to be consistent with these guidelines.
88
@@ -27,7 +27,7 @@ Configuring Flake8
2727Flake8 supports configuring a specific set of style rules to
2828enforce. This configuration can be stored in your library in a
2929``setup.cfg ``, ``tox.ini ``, or ``.flake8 `` file. PyAnsys libraries
30- store the flake8 configuration in a ``.flake8 `` file at the root of the
30+ store the Flake8 configuration in a ``.flake8 `` file at the root of the
3131repository.
3232
3333Here is an example of a ``.flake8 `` configuration file from a PyAnsys
@@ -44,48 +44,50 @@ library:
4444 statistics = True
4545
4646 Flake8 has many options that can be set within the configuration file.
47- A list of possible options can be found `here <https://flake8.pycqa.org/en/latest/user/options.html >`__.
47+ For a list and descriptions, see this `Flake8 documentation topic
48+ <https://flake8.pycqa.org/en/latest/user/options.html> `__.
4849
49- The above configuration defines the following options:
50+ The example configuration defines the following options:
5051
5152- ``exclude ``
52- This denotes subdirectories and ``doc/_build ``, along with all
53+ Denotes subdirectories and ``doc/_build ``, along with all
5354 ``__init__.py `` files to be excluded from the check.
5455
5556- ``select ``
56- This is a sequence of error codes that flake8 will report errors
57+ Sequence of error codes that Flake8 will report errors
5758 for. The set in the above configuration is a basic set of errors to
5859 check for and is not an exhaustive list.
5960
60- A full list of error codes and their descriptions can be found `here <https://flake8.pycqa.org/en/3.9.2/user/error-codes.html >`__.
61+ For a full list of error codes and their descriptions, see this `Flake8
62+ documentation topic <https://flake8.pycqa.org/en/3.9.2/user/error-codes.html> `__.
6163
6264- ``count ``
63- The total number of errors is printed at the end of the check.
65+ Total number of errors to print at the end of the check.
6466
6567- ``max-complexity ``
66- This sets the maximum allowed McCabe complexity value for a block of code.
68+ Sets the maximum allowed McCabe complexity value for a block of code.
6769 The value of 10 was chosen because it is a common default.
6870
6971- ``max-line-length ``
70- This denotes the maximum line length for any one line of code.
72+ Denotes the maximum line length for any one line of code.
7173 The `PEP8 `_ standard advises a maximum line length of 79. Because
7274 this is a bit limiting in some cases, the maximum line length
7375 recommended for a PyAnsys library is 100.
7476
7577- ``statistics ``
76- This enables the number of occurrences of each error or warning code
78+ Number of occurrences of each error or warning code
7779 to be printed as a report at the end of the check.
7880
7981
8082Running Flake8
8183--------------
82- First, to install flake8 , run:
84+ First, to install Flake8 , run:
8385
8486.. code ::
8587
8688 python -m pip install flake8
8789
88- Then, flake8 can be run from inside your project directory by executing:
90+ Then, you can run Flake8 from inside your project directory by executing:
8991
9092.. code ::
9193
@@ -95,7 +97,7 @@ This uses the configuration defined in the ``.flake8`` file to
9597run the style checks on the appropriate files within the project and
9698report any errors.
9799
98- In PyAnsys libraries, flake8 is run as part of the CI/CD for code style.
100+ In PyAnsys libraries, Flake8 is run as part of the CI/CD for code style.
99101This action is run as a required check on pull requests, preventing
100102code in violation of style rules from being merged into the code
101103base.
@@ -110,12 +112,12 @@ the formatting tool `black`_.
110112
111113On completing a code change, and before committing, `black `_ can be
112114run to reformat the code, following the PEP8 guidelines enforced through
113- flake8 . This will limit any manual code changes needed to address style
115+ Flake8 . This will limit any manual code changes needed to address style
114116rules.
115117
116118.. _black : https://black.readthedocs.io/en/stable/
117119
118- Optionally, it is possible to automate the use of `` black `` . This can be
120+ Optionally, it is possible to automate the use of `black `_ . This can be
119121done with the tool `pre-commit `_. Setting up a `pre-commit hook
120122to run black <https://black.readthedocs.io/en/stable/integrations/source_version_control.html> `_
121123will automatically format the code before committing. This simple way of
@@ -128,7 +130,7 @@ PEP8 guidelines requires minimal manual effort.
128130Minimum Standards
129131~~~~~~~~~~~~~~~~~
130132The following section describes the minimum set of code style standards
131- expected in an PyAnsys library.
133+ expected in a PyAnsys library.
132134
133135* `W191 `_ - **Indentation contains tabs. **
134136
@@ -193,11 +195,11 @@ expected in an PyAnsys library.
193195* `E501 `_ - **Line too long. **
194196
195197 All code lines should not exceed 100 characters. The
196- `PEP8 line length <https://www.python.org/dev/peps/pep-0008/#maximum-line-length >`_
197- guidelines suggest a maximum line length of 79. Following this limit
198+ `PEP8 line length guideline <https://www.python.org/dev/peps/pep-0008/#maximum-line-length >`_
199+ suggests a maximum line length of 79. Following this limit
198200 is not as necessary today due to modern screen sizes. The suggested maximum
199201 length of 100 can be easier to accommodate and can still support
200- viewing files side-by- side in code editors.
202+ viewing files side by side in code editors.
201203
202204* `F401 `_ - **Module imported but unused. **
203205
0 commit comments