Commits

Chris Adams  committed d06ec12

Updated to 0.6.0 (latest open-source release) with --max-line-length

  • Participants
  • Parent commits a1d2d90

Comments (0)

Files changed (1)

File flake8/pep8.py

 #!/usr/bin/python
-# flake8: noqa
 # pep8.py - Check Python source code formatting, according to PEP 8
 # Copyright (C) 2006 Johann C. Rocholl <johann@rocholl.net>
 #
 
 """
 
-__version__ = '0.6.1'
+__version__ = '0.6.0'
 
 import os
 import sys
 except NameError:
     from sets import ImmutableSet as frozenset
 
-from flake8.util import skip_line
 
 DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git'
 DEFAULT_IGNORE = 'E24'
     """
     line = physical_line.rstrip()
     length = len(line)
-    if length > MAX_LINE_LENGTH:
+    if length > options.max_line_length:
         try:
             # The line could contain multi-byte characters
             if not hasattr(line, 'decode'):   # Python 3
             length = len(line.decode('utf-8'))
         except UnicodeDecodeError:
             pass
-    if length > MAX_LINE_LENGTH:
-        return MAX_LINE_LENGTH, "E501 line too long (%d characters)" % length
+    if length > options.max_line_length:
+        return options.max_line_length, \
+            "E501 line too long (%d characters)" % length
 
 
 ##############################################################################
 
 if '' == ''.encode():
     # Python 2: implicit encoding.
-
     def readlines(filename):
         return open(filename).readlines()
 else:
     # Python 3: decode to latin-1.
     # This function is lazy, it does not read the encoding declaration.
     # XXX: use tokenize.detect_encoding()
-
-    def readlines(filename):        # NOQA
+    def readlines(filename):
         return open(filename, encoding='latin-1').readlines()
 
 
         """
         Report an error, according to options.
         """
-        if skip_line(self.physical_line):
-            return
         code = text[:4]
         if ignore_code(code):
             return
             # Don't care about expected errors or warnings
             return
         self.file_errors += 1
-        if options.counters[code] == 1 or not options.no_repeat:
+        if options.counters[code] == 1 or options.repeat:
             message("%s:%s:%d: %s" %
                     (self.filename, self.line_offset + line_number,
                      offset + 1, text))
     """
     if options.verbose:
         message('checking ' + filename)
-    errors = Checker(filename).check_all()
-    return errors
+    return Checker(filename).check_all()
 
 
 def input_dir(dirname, runner=None):
     global options, args
     parser = OptionParser(version=__version__,
                           usage="%prog [options] input ...")
-    parser.add_option('--max-complexity', default=-1, action='store',
-                      type='int', help="McCabe complexity treshold")
     parser.add_option('-v', '--verbose', default=0, action='count',
                       help="print status messages, or debug with -vv")
     parser.add_option('-q', '--quiet', default=0, action='count',
                       help="report only file names, or nothing with -qq")
-    parser.add_option('-r', '--no-repeat', action='store_true',
-                      help="don't show all occurrences of the same error")
+    parser.add_option('-r', '--repeat', action='store_true',
+                      help="show all occurrences of the same error")
     parser.add_option('--exclude', metavar='patterns', default=DEFAULT_EXCLUDE,
                       help="exclude files or directories which match these "
                         "comma separated patterns (default: %s)" %
                       help="measure processing speed")
     parser.add_option('--testsuite', metavar='dir',
                       help="run regression tests from dir")
+    parser.add_option('--max-line-length', type='int', metavar='n',
+                      default=MAX_LINE_LENGTH,
+                      help="set to a higher value to relax pep8 "
+                      "line length restictions")
     parser.add_option('--doctest', action='store_true',
                       help="run doctest on myself")
     options, args = parser.parse_args(arglist)