Commits

Ian Cordasco  committed d5d765f Merge

Forgot to pull first.

I am an idiot.

  • Participants
  • Parent commits 14cd3ab, e8e1bba
  • Branches refactor

Comments (0)

Files changed (3)

File flake8/hooks.py

 
 def hg_hook(ui, repo, **kwargs):
     from flake8.main import check_file
-    _initpep8()
     complexity = ui.config('flake8', 'complexity', default=-1)
+    config = ui.config('flake8', 'config', default=True)
+    _initpep8(config_file=config)
     warnings = 0
 
     for file_ in _get_files(repo, **kwargs):

File flake8/main.py

         if os.path.isdir(path):
             for dirpath, dirnames, filenames in os.walk(path):
                 if pep8style.excluded(dirpath):
+                    dirnames[:] = []
                     continue
                 for filename in filenames:
                     if not filename.endswith('.py'):

File flake8/util.py

 
 def skip_warning(warning, ignore=[]):
     # XXX quick dirty hack, just need to keep the line in the warning
-    if not hasattr(warning, 'message'):
+    if not hasattr(warning, 'message') or ignore is None:
         # McCabe's warnings cannot be skipped afaik, and they're all strings.
+        # And we'll get a TypeError otherwise
         return False
     if warning.message.split()[0] in ignore:
         return True
     return _NOQA.search(content) is not None
 
 
-def _initpep8():
+def _initpep8(config_file=True):
     # default pep8 setup
     global pep8style
     import pep8
     if pep8style is None:
-        pep8style = pep8.StyleGuide(config_file=True)
+        pep8style = pep8.StyleGuide(config_file=config_file)
     pep8style.options.physical_checks = pep8.find_checks('physical_line')
     pep8style.options.logical_checks = pep8.find_checks('logical_line')
     pep8style.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
     pep8style.options.messages = {}
-    pep8style.options.max_line_length = 79
+    if not pep8style.options.max_line_length:
+        pep8style.options.max_line_length = 79
     pep8style.args = []
     return pep8style