Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flake8 pre-commit #10

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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