Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit ca46095

Browse files
committed
update pre-commit hooks
1 parent dcd7486 commit ca46095

File tree

3 files changed

+85
-11
lines changed

3 files changed

+85
-11
lines changed

.pre-commit-config.yaml

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
repos:
2+
- repo: https://github.com/timothycrosley/isort
3+
rev: 5.0.7
4+
hooks:
5+
- id: isort
26
- repo: https://github.com/ambv/black
3-
rev: stable
7+
rev: 19.10b0
48
hooks:
59
- id: black
6-
language_version: python3.7
7-
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v2.2.3
9-
hooks:
10-
- id: trailing-whitespace
11-
language_version: python3.7
12-
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v2.2.3
10+
- repo: https://gitlab.com/pycqa/flake8
11+
rev: 3.8.3
1412
hooks:
15-
- id: debug-statements
16-
language_version: python3.7
13+
- id: flake8
14+
alias: flake8
15+
name: flake8
16+
args: ["--config=python/.flake8"]
17+
types: [python]

CONTRIBUTING.md

+60
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,66 @@ implementation of the issue, ask them in the issue instead of the PR.
5151

5252
## Setting Up Your Build Environment
5353

54+
### Code Formatting
55+
56+
#### Python
57+
58+
CLX uses [Black](https://black.readthedocs.io/en/stable/),
59+
[isort](https://readthedocs.org/projects/isort/), and
60+
[flake8](http://flake8.pycqa.org/en/latest/) to ensure a consistent code format
61+
throughout the project. `Black`, `isort`, and `flake8` can be installed with
62+
`conda` or `pip`:
63+
64+
```bash
65+
conda install black isort flake8
66+
```
67+
68+
```bash
69+
pip install black isort flake8
70+
```
71+
72+
These tools are used to auto-format the Python code, as well as check the Cython
73+
code in the repository. Additionally, there is a CI check in place to enforce
74+
that committed code follows our standards. You can use the tools to
75+
automatically format your python code by running:
76+
77+
```bash
78+
isort --atomic python/**/*.py
79+
black python
80+
```
81+
82+
and then check the syntax of your Python code by running:
83+
84+
```bash
85+
flake8 python
86+
```
87+
88+
Additionally, many editors have plugins that will apply `isort` and `Black` as
89+
you edit files, as well as use `flake8` to report any style / syntax issues.
90+
91+
#### Pre-commit hooks
92+
93+
Optionally, you may wish to setup [pre-commit hooks](https://pre-commit.com/)
94+
to automatically run `isort`, `Black`, and `flake8` when you make a git commit.
95+
This can be done by installing `pre-commit` via `conda` or `pip`:
96+
97+
```bash
98+
conda install -c conda-forge pre_commit
99+
```
100+
101+
```bash
102+
pip install pre-commit
103+
```
104+
105+
and then running:
106+
107+
```bash
108+
pre-commit install
109+
```
110+
111+
from the root of the CLX repository. Now `isort`, `Black`, and `flake8` will be
112+
run each time you commit changes.
113+
54114
### Build from Source
55115

56116
The following instructions are for developers and contributors to CLX OSS development. These instructions are tested on Linux Ubuntu 16.04 & 18.04. Use these instructions to build CLX from source and contribute to its development. Other operating systems may be compatible, but are not currently tested.

python/.flake8

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2020, NVIDIA CORPORATION.
2+
3+
[flake8]
4+
exclude = factory.py,perfect_hash.py
5+
ignore =
6+
# line break before binary operator
7+
W503
8+
# whitespace before :
9+
E203
10+
# line too long (82 > 79 characters)
11+
E501
12+
# invalid escape sequence ‘x’
13+
W605

0 commit comments

Comments
 (0)