Skip to content

Commit 05a9f5e

Browse files
authored
Merge pull request #543 from dekoza/feature/pre-commit
Add pre-commit hooks
2 parents ef51288 + 681e78c commit 05a9f5e

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ nosetests.xml
4141
.mr.developer.cfg
4242
.project
4343
.pydevproject
44+
45+
# PyCharm
46+
.idea

.pre-commit-hooks.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- id: futurize
2+
name: futurize
3+
description: Futurize your Py2 code to ensure it is runnable on Py3.
4+
language: python
5+
types: [python]
6+
entry: futurize -w -n --no-diffs
7+
args: [--stage1]
8+
9+
- id: pasteurize
10+
name: pasteurize
11+
description: Pasteurize your Py3 code to ensure it is runnable on Py2.
12+
language: python
13+
language_version: python3
14+
types: [python]
15+
entry: pasteurize -w -n --no-diffs

README.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Features
5757
decoding the backported ``str`` and ``bytes`` objects. [This feature is
5858
currently in alpha.]
5959

60+
- support for pre-commit hooks
61+
6062
.. _code-examples:
6163

6264
Code examples
@@ -261,6 +263,39 @@ development, and will likely never be perfect.
261263

262264
For more info, see :ref:`translation`.
263265

266+
Pre-commit hooks
267+
----------------
268+
269+
`Pre-commit <https://pre-commit.com/>`_ is a framework for managing and maintaining
270+
multi-language pre-commit hooks.
271+
272+
In case you need to port your project from Python 2 to Python 3, you might consider
273+
using such hook during the transition period.
274+
275+
First:
276+
277+
.. code-block:: bash
278+
279+
$ pip install pre-commit
280+
281+
and then in your project's directory:
282+
283+
.. code-block:: bash
284+
285+
$ pre-commit install
286+
287+
Next, you need to add this entry to your ``.pre-commit-config.yaml``
288+
289+
.. code-block:: yaml
290+
291+
- repo: https://github.com/PythonCharmers/python-future
292+
rev: master
293+
hooks:
294+
- id: futurize
295+
args: [--both-stages]
296+
297+
The ``args`` part is optional, by default only stage1 is applied.
298+
264299
Licensing
265300
---------
266301

0 commit comments

Comments
 (0)