Tarek Ziadé avatar Tarek Ziadé committed 945c398 Merge

Merged in huhao/flake8 (pull request #25)

Comments (0)

Files changed (3)

     STRICT = False
 
     if __name__ == '__main__':
-        sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT))
+        sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT, ignore='E501'))
 
 
 If *strict* option is set to **True**, any warning will block the commit. When
 
 import optparse
 import sys
+from flake8.util import skip_warning
 from collections import defaultdict
 
 WARNING_CODE = "W901"
             # ?
             continue
         if graph.complexity() >= min:
-            msg = '%s:%d:1: %s %r is too complex (%d)' % (
-                filename,
-                graph.lineno,
-                WARNING_CODE,
-                graph.entity,
-                graph.complexity(),
-            )
-            complex.append(msg)
+            graph.filename = filename
+            if not skip_warning(graph):
+                msg = '%s:%d:1: %s %r is too complex (%d)' % (
+                    filename,
+                    graph.lineno,
+                    WARNING_CODE,
+                    graph.entity,
+                    graph.complexity(),
+                )
+                complex.append(msg)
 
     if len(complex) == 0:
         return 0
     pep8.options.logical_checks = pep8.find_checks('logical_line')
     pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
     pep8.options.messages = {}
+    pep8.options.max_line_length = 79
     pep8.args = []
 
 
             [line.strip() for line in p.stderr.readlines()])
 
 
-def git_hook(complexity=-1, strict=False):
+def git_hook(complexity=-1, strict=False, ignore=None):
     _initpep8()
+    if ignore:
+        pep8.options.ignore=ignore
+
     warnings = 0
 
     _, files_modified, _ = run("git diff-index --cached --name-only HEAD")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.