Skip to content

Commit 03e58a4

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add pre-commit"
2 parents 903bbfe + 87e6828 commit 03e58a4

2 files changed

Lines changed: 69 additions & 13 deletions

File tree

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
default_language_version:
3+
# force all unspecified python hooks to run python3
4+
python: python3
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v3.4.0
8+
hooks:
9+
- id: trailing-whitespace
10+
- id: mixed-line-ending
11+
args: ['--fix', 'lf']
12+
exclude: '.*\.(svg)$'
13+
- id: check-byte-order-marker
14+
- id: check-executables-have-shebangs
15+
- id: check-merge-conflict
16+
- id: debug-statements
17+
- id: check-yaml
18+
files: .*\.(yaml|yml)$
19+
- repo: local
20+
hooks:
21+
- id: flake8
22+
name: flake8
23+
additional_dependencies:
24+
- hacking>=2.0.0
25+
- flake8-import-order>=0.13
26+
language: python
27+
entry: flake8
28+
files: '^.*\.py$'
29+
exclude: '^(doc|releasenotes|tools)/.*$'

doc/source/contributor/developing.rst

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,41 @@ Communication
66
-------------
77

88
IRC Channel
9-
===========
9+
~~~~~~~~~~~
10+
1011
The OpenStackClient team doesn't have regular meetings so if you have
1112
questions or anything you want to discuss, come to our channel:
1213
#openstack-sdks
1314

15+
1416
Testing
1517
-------
1618

1719
Tox prerequisites and installation
18-
==================================
20+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1921

2022
Install the prerequisites for Tox:
2123

2224
* On Ubuntu or Debian:
2325

2426
.. code-block:: bash
2527
26-
$ apt-get install gcc gettext python-dev libxml2-dev libxslt1-dev \
28+
$ apt-get install gcc gettext python3-dev libxml2-dev libxslt1-dev \
2729
zlib1g-dev
2830
2931
You may need to use pip install for some packages.
3032

31-
3233
* On RHEL or CentOS including Fedora:
3334

3435
.. code-block:: bash
3536
36-
$ yum install gcc python-devel libxml2-devel libxslt-devel
37+
$ yum install gcc python3-devel libxml2-devel libxslt-devel
3738
3839
* On openSUSE or SUSE linux Enterprise:
3940

4041
.. code-block:: bash
4142
42-
$ zypper install gcc python-devel libxml2-devel libxslt-devel
43+
$ zypper install gcc python3-devel libxml2-devel libxslt-devel
4344
4445
Install python-tox:
4546

@@ -59,7 +60,7 @@ To run the full suite of tests maintained within OpenStackClient.
5960
virtualenvs. You can later use the ``-r`` option with ``tox`` to rebuild
6061
your virtualenv in a similar manner.
6162

62-
To run tests for one or more specific test environments(for example, the most
63+
To run tests for one or more specific test environments (for example, the most
6364
common configuration of the latest Python version and PEP-8), list the
6465
environments with the ``-e`` option, separated by spaces:
6566

@@ -70,7 +71,7 @@ environments with the ``-e`` option, separated by spaces:
7071
See ``tox.ini`` for the full list of available test environments.
7172

7273
Running functional tests
73-
========================
74+
~~~~~~~~~~~~~~~~~~~~~~~~
7475

7576
OpenStackClient also maintains a set of functional tests that are optimally
7677
designed to be run against OpenStack's gate. Optionally, a developer may
@@ -90,7 +91,7 @@ To run a specific functional test:
9091
$ tox -e functional -- --regex functional.tests.compute.v2.test_server
9192
9293
Running with PDB
93-
================
94+
~~~~~~~~~~~~~~~~
9495

9596
Using PDB breakpoints with ``tox`` and ``testr`` normally does not work since
9697
the tests fail with a `BdbQuit` exception rather than stopping at the
@@ -109,8 +110,32 @@ For reference, the `debug`_ ``tox`` environment implements the instructions
109110
.. _`debug`: https://wiki.openstack.org/wiki/Testr#Debugging_.28pdb.29_Tests
110111

111112

112-
Building the Documentation
113-
--------------------------
113+
Coding Style
114+
------------
115+
116+
OpenStackClient uses `flake8`__ along with `hacking`__, an OpenStack-specific
117+
superset of ``flake8`` rules, to enforce coding style. This can be run manually
118+
using ``tox``:
119+
120+
.. code-block:: bash
121+
122+
$ tox -e pep8
123+
124+
Alternatively, you can use the `pre-commit framework`__ to allow running of
125+
some linters on each commit. This must be enabled locally to function:
126+
127+
.. code-block:: bash
128+
129+
$ pip install --user pre-commit
130+
$ pre-commit install --allow-missing-config
131+
132+
.. __: https://flake8.pycqa.org/en/latest/
133+
.. __: https://docs.openstack.org/hacking/latest/user/hacking.html
134+
.. __: https://pre-commit.com/
135+
136+
137+
Documentation
138+
-------------
114139

115140
The documentation is generated with Sphinx using the ``tox`` command. To
116141
create HTML docs, run the commands:
@@ -121,6 +146,7 @@ create HTML docs, run the commands:
121146
122147
The resultant HTML will be in the ``doc/build/html`` directory.
123148

149+
124150
Release Notes
125151
-------------
126152

@@ -156,6 +182,7 @@ To run the commands and see results:
156182
157183
At last, look at the generated release notes files in ``releasenotes/build/html`` in your browser.
158184

185+
159186
Testing new code
160187
----------------
161188

@@ -174,7 +201,7 @@ or
174201
$ pip install -e .
175202
176203
Standardize Import Format
177-
=========================
204+
~~~~~~~~~~~~~~~~~~~~~~~~~
178205

179206
More information about Import Format, see `Import Order Guide
180207
<https://docs.openstack.org/hacking/latest/user/hacking.html#imports>`__.
@@ -193,7 +220,7 @@ The import order shows below:
193220
{{begin your code}}
194221
195222
Example
196-
~~~~~~~
223+
^^^^^^^
197224

198225
.. code-block:: python
199226

0 commit comments

Comments
 (0)