Skip to content

Commit

Permalink
[doc] add flake8 pre-commit (#10)
Browse files Browse the repository at this point in the history
* add flake8 pre-commit

* Create CONTRIBUTING.md
  • Loading branch information
jschenxiaoyu committed Nov 30, 2020
1 parent 2ade822 commit f32a40e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing guidelines

## Pre-commit tidy/linting hook

You'll need to install flake8 first.

We use flake8 to perform additional formatting and semantic checking of code.
We provide a pre-commit git hook for performing these checks, before a commit
is created:

```bash
ln -s ../../tools/git-pre-commit .git/hooks/pre-commit
```
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flake8
pyyaml
typeguard
tensorboardX
typeguard
11 changes: 11 additions & 0 deletions tools/flake8_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys

from flake8.main import git

if __name__ == '__main__':
sys.exit(
git.hook(
strict=True,
lazy=git.config_for('lazy'),
)
)
5 changes: 5 additions & 0 deletions tools/git-pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

echo "Running pre-commit flake8"
python tools/flake8_hook.py

0 comments on commit f32a40e

Please sign in to comment.