Browse code

add pre-commit with black, flake8, and whitespace fixers

Bas Nijholt authored on 06/05/2019 20:12:32
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+repos:
2
+-   repo: https://github.com/ambv/black
3
+    rev: 19.3b0
4
+    hooks:
5
+    - id: black
6
+      language_version: python3.7
7
+-   repo: https://github.com/pre-commit/pre-commit-hooks
8
+    rev: v2.1.0
9
+    hooks:
10
+    -   id: end-of-file-fixer
11
+    -   id: trailing-whitespace
12
+-   repo: https://gitlab.com/pycqa/flake8
13
+    rev: 3.7.4
14
+    hooks:
15
+    -   id: flake8
16
+        args: ['--max-line-length=500', '--ignore=E203,E266,E501,W503', '--max-complexity=18', '--select=B,C,E,F,W,T4,B9']
... ...
@@ -113,6 +113,14 @@ please setup the git filter by executing
113 113
 
114 114
 in the repository.
115 115
 
116
+We implement several other checks in order to maintain a consistent code style. We do this using [pre-commit`](https://pre-commit.com), execute
117
+
118
+.. code:: bash
119
+
120
+    pre-commit install
121
+
122
+in the repository.
123
+
116 124
 Credits
117 125
 -------
118 126
 
... ...
@@ -24,3 +24,8 @@ steps:
24 24
 - script: ./check_whitespace
25 25
   continueOnError: true
26 26
   displayName: 'Whitespace check'
27
+
28
+- script: |
29
+    source activate adaptive
30
+    black . --check -t py36
31
+  displayName: 'Run lint tests'
... ...
@@ -3,3 +3,4 @@ pytest
3 3
 pytest-cov
4 4
 pytest-randomly
5 5
 pytest-timeout
6
+pre_commit