Skip to content

Commit 25d8782

Browse files
committed
Update both contributing guides to reflect addition of pre-commit hooks
1 parent ac753b8 commit 25d8782

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

.github/CONTRIBUTING.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,24 @@ One of the simplest ways to help with PRAW is by answering others'
2626
questions. When responding, always be positive. While something may be obvious
2727
to you, it likely is not to the person asking the question.
2828

29-
## Pull Request Creation
29+
## Creating Pull Requests
3030

3131
0. If you are fixing an already filed issue, please indicate your intentions by
3232
commenting on the issue. This act will hopefully minimize any duplicate
3333
work.
3434

35-
0. Prior to creating a pull request run the `pre_push.py` script. This script
36-
depends on the tools `black` `flake8`, `pylint`, `pydocstyle`, `sphinx` and `sphinx_rtd_theme`. They can
37-
be installed via `pip install black flake8 pydocstyle pylint sphinx sphinx_rtd_theme` or via
38-
`pip install praw[lint]`.
35+
0. Before commiting, make sure to install [Pre-Commit](https://pre-commit.com/)
36+
and the pre-commit hooks, which ensure any new code conforms to PRAW's
37+
quality and style guidelines. To do so, install the linting dependencies
38+
with `pip install praw[lint]`, then by the hooks with `pre-commit install`.
39+
They will now run automatically every time you commit. If one of the formatters
40+
(e.g. Black, isort) changes one or more files, the commit will automatically abort
41+
so you can double-check the changes. If everything looks good, just `git add .` and
42+
commit again.
43+
44+
0. Prior to creating a pull request, run the `pre_push.py` script.
45+
This runs the pre-commit suite on all files, as well as builds the docs.
46+
You'll need to have installed the linting dependencies first (see previous).
3947

4048
0. Add yourself as a contributor to the ``AUTHORS.rst``.
4149

docs/package_info/contributing.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@ PRAW gladly welcomes new contributions. As with most larger projects, we have an
55
established consistent way of doing things. A consistent style increases readability,
66
decreases bug-potential and makes it faster to understand how everything works together.
77

8-
PRAW follows :PEP:`8` and :PEP:`257`. The ``pre_push.py`` script can be used to test for
9-
compliance with these PEPs in addition to providing a few other checks. The following
10-
are PRAW-specific guidelines in addition to those PEP's.
8+
PRAW follows :PEP:`8` and :PEP:`257`. `Pre-Commit <https://pre-commit.com>` is used to
9+
manage a suite of pre-commit hooks that enforce conformance with these PEPs along with
10+
several other checks. Additionally, the ``pre_push.py`` script can be used to run the
11+
full pre-commit suite and the docs build prior to submitting a Pull Request. The
12+
following are PRAW-specific guidelines in addition to those PEPs.
1113

1214
.. note::
1315

14-
Python 3.6+ is needed to run the script.
15-
16-
.. note::
17-
18-
In order to install the dependencies needed to run the script, you can install the
19-
``[dev]`` package of praw, like so:
16+
In order to use the pre-commit hooks and the ``pre_push.py`` dependencies, install
17+
PRAW's ``[lint]`` extra, followed by the appropriate Pre-Commit command:
2018

2119
.. code-block:: bash
2220
23-
pip install praw[dev]
21+
pip install praw[lint]
22+
pre-commit install
2423
2524
Code
2625
----
@@ -78,9 +77,9 @@ The environment variables are (listed in bash export format):
7877
export prawtest_username=myusername
7978
export prawtest_user_agent=praw_pytest
8079
81-
By setting these environment variables prior to running ``python setup.py test``, when
82-
adding or updating cassettes, instances of ``mypassword`` will be replaced by the
83-
placeholder text ``<PASSWORD>`` and similar for the other environment variables.
80+
By setting these environment variables prior to running ``pytest``, when adding or
81+
updating cassettes, instances of ``mypassword`` will be replaced by the placeholder text
82+
``<PASSWORD>`` and similar for the other environment variables.
8483

8584
To use tokens instead of username/password set ``prawtest_refresh_token`` instead of
8685
``prawtest_password`` and ``prawtest_username``.
@@ -105,7 +104,8 @@ Static Checker
105104

106105
PRAW's test suite comes with a checker tool that can warn you of using incorrect
107106
documentation styles (using ``.. code-block::`` instead of ``.. code::``, using ``/r/``
108-
instead of ``r/``, etc.).
107+
instead of ``r/``, etc.). This is run automatically by the pre-commit hooks and the
108+
``pre_push.py`` script.
109109

110110
.. autoclass:: tools.static_word_checks.StaticChecker
111111
:inherited-members:

0 commit comments

Comments
 (0)