Hello community,

here is the log from the commit of package python-autopep8 for openSUSE:Factory 
checked in at 2015-04-23 08:04:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-autopep8 (Old)
 and      /work/SRC/openSUSE:Factory/.python-autopep8.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-autopep8"

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-autopep8/python-autopep8.changes  
2014-11-18 22:45:35.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.python-autopep8.new/python-autopep8.changes     
2015-04-23 08:04:23.000000000 +0200
@@ -1,0 +2,6 @@
+Tue Apr 21 18:02:55 UTC 2015 - benoit.mo...@gmx.fr
+
+- update to 1.1.1: no upstream changelog
+- add -q to test to avoid spamming the build log
+
+-------------------------------------------------------------------

Old:
----
  autopep8-1.0.3.tar.gz

New:
----
  autopep8-1.1.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-autopep8.spec ++++++
--- /var/tmp/diff_new_pack.kb4myr/_old  2015-04-23 08:04:23.000000000 +0200
+++ /var/tmp/diff_new_pack.kb4myr/_new  2015-04-23 08:04:23.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-autopep8
 #
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           python-autopep8
-Version:        1.0.3
+Version:        1.1.1
 Release:        0
 Url:            https://github.com/hhatto/autopep8
 Summary:        Automatic generated to pep8 checked code
@@ -57,7 +57,7 @@
 %check
 # need to set locale to avoid UnicodeEncodeError
 export LANG="en_US.UTF-8"
-python setup.py test
+python setup.py test -q
 
 %pre
 # Since /usr/bin/autopep8 became ghosted to be used with update-alternatives, 
we have to get rid

++++++ autopep8-1.0.3.tar.gz -> autopep8-1.1.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/AUTHORS.rst 
new/autopep8-1.1.1/AUTHORS.rst
--- old/autopep8-1.0.3/AUTHORS.rst      2014-03-29 15:23:30.000000000 +0100
+++ new/autopep8-1.1.1/AUTHORS.rst      2014-12-25 03:20:09.000000000 +0100
@@ -19,3 +19,6 @@
 - Christopher Medrela (https://github.com/chrismedrela)
 - 小明 (https://github.com/dongweiming)
 - Andy Hayden (https://github.com/hayd)
+- Fabio Zadrozny (https://github.com/fabioz)
+- Alex Chernetz (https://github.com/achernet)
+- Marc Schlaich (https://github.com/schlamar)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/LICENSE new/autopep8-1.1.1/LICENSE
--- old/autopep8-1.0.3/LICENSE  2014-04-11 03:54:44.000000000 +0200
+++ new/autopep8-1.1.1/LICENSE  2015-02-26 06:48:37.000000000 +0100
@@ -1,6 +1,6 @@
 Copyright (C) 2010-2011 Hideo Hattori
 Copyright (C) 2011-2013 Hideo Hattori, Steven Myint
-Copyright (C) 2013-2014 Hideo Hattori, Steven Myint, Bill Wendling
+Copyright (C) 2013-2015 Hideo Hattori, Steven Myint, Bill Wendling
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/MANIFEST.in 
new/autopep8-1.1.1/MANIFEST.in
--- old/autopep8-1.0.3/MANIFEST.in      2014-05-08 16:31:05.000000000 +0200
+++ new/autopep8-1.1.1/MANIFEST.in      2015-02-26 06:35:07.000000000 +0100
@@ -10,6 +10,7 @@
 include test/example_with_reduce.py
 include test/example.py
 include test/iso_8859_1.py
+include test/fake_configuration/.pep8
 recursive-exclude test/suite *.py
 recursive-exclude test/suite/out *.py
 exclude .travis.yml
@@ -21,7 +22,6 @@
 exclude install_hooks.bash
 exclude test/.gitignore
 exclude test/acid.py
-exclude test/acid_github.py
 exclude test/acid_pypi.py
 exclude test/suite
 exclude test/suite/out
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/PKG-INFO new/autopep8-1.1.1/PKG-INFO
--- old/autopep8-1.0.3/PKG-INFO 2014-06-10 14:47:48.000000000 +0200
+++ new/autopep8-1.1.1/PKG-INFO 2015-02-26 06:58:32.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: autopep8
-Version: 1.0.3
+Version: 1.1.1
 Summary: A tool that automatically formats Python code to conform to the PEP 8 
style guide
 Home-page: https://github.com/hhatto/autopep8
 Author: Hideo Hattori
@@ -132,7 +132,8 @@
         
         Options::
         
-            usage: autopep8 [-h] [--version] [-v] [-d] [-i] [-r] [-j n] [-p n] 
[-a]
+            usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config 
filename]
+                            [--ignore-local-config] [-r] [-j n] [-p n] [-a]
                             [--experimental] [--exclude globs] [--list-fixes]
                             [--ignore errors] [--select errors] 
[--max-line-length n]
                             [--range line line] [--indent-size n]
@@ -150,6 +151,14 @@
                                     verbose messages
               -d, --diff            print the diff for the fixed source
               -i, --in-place        make changes to files in place
+              --global-config filename
+                                    path to a global pep8 config file; if this 
file does
+                                    not exist then this is ignored (default:
+                                    ~/.config/pep8)
+              --ignore-local-config
+                                    don't look for and apply local config 
files; if not
+                                    passed, defaults are updated with any 
config files in
+                                    the project's root directory
               -r, --recursive       run recursively over directories; must be 
used with
                                     --in-place or --diff
               -j n, --jobs n        number of parallel jobs; match CPU count 
if value is
@@ -319,8 +328,7 @@
         autopep8 against Python code and checks for correctness and 
completeness of the
         code fixes. It can check that the bytecode remains identical.
         ``test/acid_pypi.py`` makes use of ``acid.py`` to test against the 
latest
-        released packages on PyPI. In a similar fashion, 
``test/acid_github.py`` tests
-        against Python code in Github repositories.
+        released packages on PyPI.
         
         
         Troubleshooting
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/README.rst 
new/autopep8-1.1.1/README.rst
--- old/autopep8-1.0.3/README.rst       2014-06-10 14:41:58.000000000 +0200
+++ new/autopep8-1.1.1/README.rst       2014-12-25 03:20:09.000000000 +0100
@@ -124,7 +124,8 @@
 
 Options::
 
-    usage: autopep8 [-h] [--version] [-v] [-d] [-i] [-r] [-j n] [-p n] [-a]
+    usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]
+                    [--ignore-local-config] [-r] [-j n] [-p n] [-a]
                     [--experimental] [--exclude globs] [--list-fixes]
                     [--ignore errors] [--select errors] [--max-line-length n]
                     [--range line line] [--indent-size n]
@@ -142,6 +143,14 @@
                             verbose messages
       -d, --diff            print the diff for the fixed source
       -i, --in-place        make changes to files in place
+      --global-config filename
+                            path to a global pep8 config file; if this file 
does
+                            not exist then this is ignored (default:
+                            ~/.config/pep8)
+      --ignore-local-config
+                            don't look for and apply local config files; if not
+                            passed, defaults are updated with any config files 
in
+                            the project's root directory
       -r, --recursive       run recursively over directories; must be used with
                             --in-place or --diff
       -j n, --jobs n        number of parallel jobs; match CPU count if value 
is
@@ -311,8 +320,7 @@
 autopep8 against Python code and checks for correctness and completeness of the
 code fixes. It can check that the bytecode remains identical.
 ``test/acid_pypi.py`` makes use of ``acid.py`` to test against the latest
-released packages on PyPI. In a similar fashion, ``test/acid_github.py`` tests
-against Python code in Github repositories.
+released packages on PyPI.
 
 
 Troubleshooting
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/autopep8.egg-info/PKG-INFO 
new/autopep8-1.1.1/autopep8.egg-info/PKG-INFO
--- old/autopep8-1.0.3/autopep8.egg-info/PKG-INFO       2014-06-10 
14:47:48.000000000 +0200
+++ new/autopep8-1.1.1/autopep8.egg-info/PKG-INFO       2015-02-26 
06:58:32.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: autopep8
-Version: 1.0.3
+Version: 1.1.1
 Summary: A tool that automatically formats Python code to conform to the PEP 8 
style guide
 Home-page: https://github.com/hhatto/autopep8
 Author: Hideo Hattori
@@ -132,7 +132,8 @@
         
         Options::
         
-            usage: autopep8 [-h] [--version] [-v] [-d] [-i] [-r] [-j n] [-p n] 
[-a]
+            usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config 
filename]
+                            [--ignore-local-config] [-r] [-j n] [-p n] [-a]
                             [--experimental] [--exclude globs] [--list-fixes]
                             [--ignore errors] [--select errors] 
[--max-line-length n]
                             [--range line line] [--indent-size n]
@@ -150,6 +151,14 @@
                                     verbose messages
               -d, --diff            print the diff for the fixed source
               -i, --in-place        make changes to files in place
+              --global-config filename
+                                    path to a global pep8 config file; if this 
file does
+                                    not exist then this is ignored (default:
+                                    ~/.config/pep8)
+              --ignore-local-config
+                                    don't look for and apply local config 
files; if not
+                                    passed, defaults are updated with any 
config files in
+                                    the project's root directory
               -r, --recursive       run recursively over directories; must be 
used with
                                     --in-place or --diff
               -j n, --jobs n        number of parallel jobs; match CPU count 
if value is
@@ -319,8 +328,7 @@
         autopep8 against Python code and checks for correctness and 
completeness of the
         code fixes. It can check that the bytecode remains identical.
         ``test/acid_pypi.py`` makes use of ``acid.py`` to test against the 
latest
-        released packages on PyPI. In a similar fashion, 
``test/acid_github.py`` tests
-        against Python code in Github repositories.
+        released packages on PyPI.
         
         
         Troubleshooting
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/autopep8.egg-info/SOURCES.txt 
new/autopep8-1.1.1/autopep8.egg-info/SOURCES.txt
--- old/autopep8-1.0.3/autopep8.egg-info/SOURCES.txt    2014-06-10 
14:47:48.000000000 +0200
+++ new/autopep8-1.1.1/autopep8.egg-info/SOURCES.txt    2015-02-26 
06:58:32.000000000 +0100
@@ -3,6 +3,7 @@
 MANIFEST.in
 README.rst
 autopep8.py
+setup.cfg
 setup.py
 autopep8.egg-info/PKG-INFO
 autopep8.egg-info/SOURCES.txt
@@ -19,4 +20,5 @@
 test/example_with_reduce.py
 test/iso_8859_1.py
 test/test_autopep8.py
-test/test_suite.py
\ No newline at end of file
+test/test_suite.py
+test/fake_configuration/.pep8
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/autopep8.egg-info/requires.txt 
new/autopep8-1.1.1/autopep8.egg-info/requires.txt
--- old/autopep8-1.0.3/autopep8.egg-info/requires.txt   2014-06-10 
14:47:48.000000000 +0200
+++ new/autopep8-1.1.1/autopep8.egg-info/requires.txt   2015-02-26 
06:58:32.000000000 +0100
@@ -1 +1 @@
-pep8 >= 1.5.7
\ No newline at end of file
+pep8 >= 1.5.7
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/autopep8.py 
new/autopep8-1.1.1/autopep8.py
--- old/autopep8-1.0.3/autopep8.py      2014-06-10 14:45:35.000000000 +0200
+++ new/autopep8-1.1.1/autopep8.py      2015-02-26 06:57:06.000000000 +0100
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2010-2011 Hideo Hattori
 # Copyright (C) 2011-2013 Hideo Hattori, Steven Myint
-# Copyright (C) 2013-2014 Hideo Hattori, Steven Myint, Bill Wendling
+# Copyright (C) 2013-2015 Hideo Hattori, Steven Myint, Bill Wendling
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -67,7 +67,7 @@
     unicode = str
 
 
-__version__ = '1.0.3'
+__version__ = '1.1.1'
 
 
 CR = '\r'
@@ -95,6 +95,7 @@
 
 # W602 is handled separately due to the need to avoid "with_traceback".
 CODE_TO_2TO3 = {
+    'E231': ['ws_comma'],
     'E721': ['idioms'],
     'W601': ['has_key'],
     'W603': ['ne'],
@@ -102,7 +103,6 @@
     'W690': ['apply',
              'except',
              'exitfunc',
-             'import',
              'numliterals',
              'operator',
              'paren',
@@ -115,6 +115,14 @@
              'xreadlines']}
 
 
+if sys.platform == 'win32':  # pragma: no cover
+    DEFAULT_CONFIG = os.path.expanduser(r'~\.pep8')
+else:
+    DEFAULT_CONFIG = os.path.join(os.getenv('XDG_CONFIG_HOME') or
+                                  os.path.expanduser('~/.config'), 'pep8')
+PROJECT_CONFIG = ('setup.cfg', 'tox.ini', '.pep8')
+
+
 def open_with_encoding(filename, encoding=None, mode='r'):
     """Return opened file with a specific encoding."""
     if not encoding:
@@ -148,6 +156,7 @@
 
 def extended_blank_lines(logical_line,
                          blank_lines,
+                         blank_before,
                          indent_level,
                          previous_logical):
     """Check for missing blank lines after class declaration."""
@@ -156,7 +165,7 @@
             logical_line.startswith(('def ', 'class ', '@')) or
             pep8.DOCSTRING_REGEX.match(logical_line)
         ):
-            if indent_level and not blank_lines:
+            if indent_level and not blank_lines and not blank_before:
                 yield (0, 'E309 expected 1 blank line after class declaration')
     elif previous_logical.startswith('def '):
         if blank_lines and pep8.DOCSTRING_REGEX.match(logical_line):
@@ -166,6 +175,7 @@
         if (
             indent_level and
             not blank_lines and
+            not blank_before and
             logical_line.startswith(('def ')) and
             '(self' in logical_line
         ):
@@ -285,8 +295,11 @@
                 yield (start, '{0} {1}'.format(*error))
 
         # Look for visual indenting.
-        if (parens[row] and token_type not in (tokenize.NL, tokenize.COMMENT)
-                and not indent[depth]):
+        if (
+            parens[row] and
+            token_type not in (tokenize.NL, tokenize.COMMENT) and
+            not indent[depth]
+        ):
             indent[depth] = start[1]
             indent_chances[start[1]] = True
         # Deal with implicit string concatenation.
@@ -441,8 +454,7 @@
             options and (options.aggressive >= 2 or options.experimental) else
             self.fix_long_line_physically)
         self.fix_e703 = self.fix_e702
-
-        self._ws_comma_done = False
+        self.fix_w293 = self.fix_w291
 
     def _fix_source(self, results):
         try:
@@ -641,17 +653,6 @@
 
     def fix_e231(self, result):
         """Add missing whitespace."""
-        # Optimize for comma case. This will fix all commas in the full source
-        # code in one pass. Don't do this more than once. If it fails the first
-        # time, there is no point in trying again.
-        if ',' in result['info'] and not self._ws_comma_done:
-            self._ws_comma_done = True
-            original = ''.join(self.source)
-            new = refactor(original, ['ws_comma'])
-            if original.strip() != new.strip():
-                self.source = [new]
-                return range(1, 1 + len(original))
-
         line_index = result['line'] - 1
         target = self.source[line_index]
         offset = result['column']
@@ -894,7 +895,15 @@
         second = (_get_indentation(logical_lines[0]) +
                   target[offset:].lstrip(';').lstrip())
 
-        self.source[line_index] = first + '\n' + second
+        # find inline commnet
+        inline_comment = None
+        if '# ' == target[offset:].lstrip(';').lstrip()[:2]:
+            inline_comment = target[offset:].lstrip(';')
+
+        if inline_comment:
+            self.source[line_index] = first + inline_comment
+        else:
+            self.source[line_index] = first + '\n' + second
         return [line_index + 1]
 
     def fix_e711(self, result):
@@ -1014,10 +1023,7 @@
 
     if verbose >= 4:
         print(('-' * 79 + '\n').join([''] + candidates + ['']),
-              file=codecs.getwriter('utf-8')(sys.stderr.buffer
-                                             if hasattr(sys.stderr,
-                                                        'buffer')
-                                             else sys.stderr))
+              file=wrap_output(sys.stderr, 'utf-8'))
 
     if candidates:
         return candidates[0]
@@ -1171,11 +1177,13 @@
 
             # Normalize beginning if not a shebang.
             if len(line) > 1:
+                pos = next((index for index, c in enumerate(line)
+                            if c != '#'))
                 if (
                     # Leave multiple spaces like '#    ' alone.
-                    (line.count('#') > 1 or line[1].isalnum())
+                    (line[:pos].count('#') > 1 or line[1].isalnum()) and
                     # Leave stylistic outlined blocks alone.
-                    and not line.rstrip().endswith('#')
+                    not line.rstrip().endswith('#')
                 ):
                     line = '# ' + line.lstrip('# \t')
 
@@ -1186,7 +1194,7 @@
     return ''.join(fixed_lines)
 
 
-def refactor(source, fixer_names, ignore=None):
+def refactor(source, fixer_names, ignore=None, filename=''):
     """Return refactored code using lib2to3.
 
     Skip if ignore string is produced in the refactored code.
@@ -1195,7 +1203,8 @@
     from lib2to3 import pgen2
     try:
         new_text = refactor_with_2to3(source,
-                                      fixer_names=fixer_names)
+                                      fixer_names=fixer_names,
+                                      filename=filename)
     except (pgen2.parse.ParseError,
             SyntaxError,
             UnicodeDecodeError,
@@ -1217,7 +1226,8 @@
     return fixes
 
 
-def fix_2to3(source, aggressive=True, select=None, ignore=None):
+def fix_2to3(source,
+             aggressive=True, select=None, ignore=None, filename=''):
     """Fix various deprecated code (via lib2to3)."""
     if not aggressive:
         return source
@@ -1227,7 +1237,8 @@
 
     return refactor(source,
                     code_to_2to3(select=select,
-                                 ignore=ignore))
+                                 ignore=ignore),
+                    filename=filename)
 
 
 def fix_w602(source, aggressive=True):
@@ -1580,7 +1591,7 @@
                  (self._prev_prev_item.is_name or
                   self._prev_prev_item.is_number or
                   self._prev_prev_item.is_string)) and
-                prev_text in ('+', '-', '%', '*', '/', '//', '**')))))
+                prev_text in ('+', '-', '%', '*', '/', '//', '**', 'in')))))
         ):
             self._lines.append(self._Space())
 
@@ -2372,7 +2383,7 @@
         return line + 'def _(): pass'
     elif line.startswith('class '):
         return line + ' pass'
-    elif line.startswith('if '):
+    elif line.startswith(('if ', 'elif ', 'for ', 'while ')):
         return line + ' pass'
     else:
         return line
@@ -2612,7 +2623,7 @@
     return i
 
 
-def refactor_with_2to3(source_text, fixer_names):
+def refactor_with_2to3(source_text, fixer_names, filename=''):
     """Use lib2to3 to refactor the source.
 
     Return the refactored source code.
@@ -2624,7 +2635,8 @@
 
     from lib2to3.pgen2 import tokenize as lib2to3_tokenize
     try:
-        return unicode(tool.refactor_string(source_text, name=''))
+        # The name parameter is necessary particularly for the "import" fixer.
+        return unicode(tool.refactor_string(source_text, name=filename))
     except lib2to3_tokenize.TokenError:
         return source_text
 
@@ -2650,6 +2662,8 @@
 
     commented_out_code_line_numbers = commented_out_code_lines(source)
 
+    has_e901 = any(result['id'].lower() == 'e901' for result in results)
+
     for r in results:
         issue_id = r['id'].lower()
 
@@ -2681,6 +2695,13 @@
             if issue_id.startswith(('e26', 'e501')):
                 continue
 
+        # Do not touch indentation if there is a token error caused by
+        # incomplete multi-line statement. Otherwise, we risk screwing up the
+        # indentation.
+        if has_e901:
+            if issue_id.startswith(('e1', 'e7')):
+                continue
+
         yield r
 
 
@@ -2815,13 +2836,17 @@
     return True
 
 
-def fix_code(source, options=None):
-    """Return fixed source code."""
+def fix_code(source, options=None, encoding=None, apply_config=False):
+    """Return fixed source code.
+
+    "encoding" will be used to decode "source" if it is a byte string.
+
+    """
     if not options:
-        options = parse_args([''])
+        options = parse_args([''], apply_config=apply_config)
 
     if not isinstance(source, unicode):
-        source = source.decode(locale.getpreferredencoding())
+        source = source.decode(encoding or get_encoding())
 
     sio = io.StringIO(source)
     return fix_lines(sio.readlines(), options=options)
@@ -2841,7 +2866,9 @@
         fixed_source = apply_local_fixes(tmp_source, options)
     else:
         # Apply global fixes only once (for efficiency).
-        fixed_source = apply_global_fixes(tmp_source, options)
+        fixed_source = apply_global_fixes(tmp_source,
+                                          options,
+                                          filename=filename)
 
     passes = 0
     long_line_ignore_cache = set()
@@ -2866,9 +2893,9 @@
     return ''.join(normalize_line_endings(sio.readlines(), original_newline))
 
 
-def fix_file(filename, options=None, output=None):
+def fix_file(filename, options=None, output=None, apply_config=False):
     if not options:
-        options = parse_args([filename])
+        options = parse_args([filename], apply_config=apply_config)
 
     original_source = readlines_from_file(filename)
 
@@ -2878,11 +2905,7 @@
         encoding = detect_encoding(filename)
 
     if output:
-        output = codecs.getwriter(encoding)(output.buffer
-                                            if hasattr(output, 'buffer')
-                                            else output)
-
-        output = LineEndingWrapper(output)
+        output = LineEndingWrapper(wrap_output(output, encoding=encoding))
 
     fixed_source = fix_lines(fixed_source, options, filename=filename)
 
@@ -2921,14 +2944,15 @@
                 yield (code, function)
 
 
-def apply_global_fixes(source, options, where='global'):
+def apply_global_fixes(source, options, where='global', filename=''):
     """Run global fixes on source code.
 
     These are fixes that only need be done once (unlike those in
     FixPEP8, which are dependent on pep8).
 
     """
-    if code_match('E101', select=options.select, ignore=options.ignore):
+    if any(code_match(code, select=options.select, ignore=options.ignore)
+           for code in ['E101', 'E111']):
         source = reindent(source,
                           indent_size=options.indent_size)
 
@@ -2944,7 +2968,8 @@
     source = fix_2to3(source,
                       aggressive=options.aggressive,
                       select=options.select,
-                      ignore=options.ignore)
+                      ignore=options.ignore,
+                      filename=filename)
 
     return source
 
@@ -2960,15 +2985,15 @@
         """Find leftmost item greater than or equal to x."""
         i = bisect.bisect_left(a, x)
         if i != len(a):
-            return i, a[i]
-        return len(a) - 1, a[-1]
+            return (i, a[i])
+        return (len(a) - 1, a[-1])
 
     def find_le(a, x):
         """Find rightmost value less than or equal to x."""
         i = bisect.bisect_right(a, x)
         if i:
-            return i - 1, a[i - 1]
-        return 0, a[0]
+            return (i - 1, a[i - 1])
+        return (0, a[0])
 
     def local_fix(source, start_log, end_log,
                   start_lines, end_lines, indents, last_line):
@@ -2992,12 +3017,20 @@
         sl = slice(start_lines[start_log], end_lines[end_log] + 1)
 
         subsource = source[sl]
+        msl = multiline_string_lines(''.join(subsource),
+                                     include_docstrings=False)
         # Remove indent from subsource.
         if ind:
             for line_no in start_lines[start_log:end_log + 1]:
                 pos = line_no - start_lines[start_log]
                 subsource[pos] = subsource[pos][ind:]
 
+            # Remove indent from comments.
+            for (i, line) in enumerate(subsource):
+                if i + 1 not in msl and re.match(r'\s*#', line):
+                    if line.index('#') >= ind:
+                        subsource[i] = line[ind:]
+
         # Fix indentation of subsource.
         fixed_subsource = apply_global_fixes(''.join(subsource),
                                              options,
@@ -3007,7 +3040,7 @@
         # Add back indent for non multi-line strings lines.
         msl = multiline_string_lines(''.join(fixed_subsource),
                                      include_docstrings=False)
-        for i, line in enumerate(fixed_subsource):
+        for (i, line) in enumerate(fixed_subsource):
             if not i + 1 in msl:
                 fixed_subsource[i] = indent + line if line != '\n' else line
 
@@ -3016,8 +3049,10 @@
         # subset up until last_line, this assumes that the number of lines
         # does not change in this multiline line.
         changed_lines = len(fixed_subsource)
-        if (start_lines[end_log] != end_lines[end_log]
-                and end_lines[end_log] > last_line):
+        if (
+            start_lines[end_log] != end_lines[end_log] and
+            end_lines[end_log] > last_line
+        ):
             after_end = end_lines[end_log] - last_line
             fixed_subsource = (fixed_subsource[:-after_end] +
                                source[sl][-after_end:])
@@ -3036,7 +3071,7 @@
         return re.split('[ :]', line.strip(), 1)[0] in continued_stmts
 
     assert options.line_range
-    start, end = options.line_range
+    (start, end) = options.line_range
     start -= 1
     end -= 1
     last_line = end  # We shouldn't modify lines after this cut-off.
@@ -3050,20 +3085,22 @@
         # Just blank lines, this should imply that it will become '\n' ?
         return apply_global_fixes(source, options)
 
-    start_lines, indents = zip(*logical[0])
-    end_lines, _ = zip(*logical[1])
+    (start_lines, indents) = zip(*logical[0])
+    (end_lines, _) = zip(*logical[1])
 
     source = source.splitlines(True)
 
-    start_log, start = find_ge(start_lines, start)
-    end_log, end = find_le(start_lines, end)
+    (start_log, start) = find_ge(start_lines, start)
+    (end_log, end) = find_le(start_lines, end)
 
     # Look behind one line, if it's indented less than current indent
     # then we can move to this previous line knowing that its
     # indentation level will not be changed.
-    if (start_log > 0
-            and indents[start_log - 1] < indents[start_log]
-            and not is_continued_stmt(source[start_log - 1])):
+    if (
+        start_log > 0 and
+        indents[start_log - 1] < indents[start_log] and
+        not is_continued_stmt(source[start_log - 1])
+    ):
         start_log -= 1
         start = start_lines[start_log]
 
@@ -3077,9 +3114,9 @@
         ind = indents[start_log]
         for t in itertools.takewhile(lambda t: t[1][1] >= ind,
                                      enumerate(logical[0][start_log:])):
-            n_log, n = start_log + t[0], t[1][0]
-        # start shares indent up to n.
+            (n_log, n) = start_log + t[0], t[1][0]
 
+        # Start shares indent up to n.
         if n <= end:
             source = local_fix(source, start_log, n_log,
                                start_lines, end_lines,
@@ -3090,15 +3127,17 @@
 
         else:
             # Look at the line after end and see if allows us to reindent.
-            after_end_log, after_end = find_ge(start_lines, end + 1)
+            (after_end_log, after_end) = find_ge(start_lines, end + 1)
 
             if indents[after_end_log] > indents[start_log]:
-                start_log, start = find_ge(start_lines, start + 1)
+                (start_log, start) = find_ge(start_lines, start + 1)
                 continue
 
-            if (indents[after_end_log] == indents[start_log]
-                    and is_continued_stmt(source[after_end])):
-                # find n, the beginning of the last continued statement
+            if (
+                indents[after_end_log] == indents[start_log] and
+                is_continued_stmt(source[after_end])
+            ):
+                # Find n, the beginning of the last continued statement.
                 # Apply fix to previous block if there is one.
                 only_block = True
                 for n, n_ind in logical[0][start_log:end_log + 1][::-1]:
@@ -3112,7 +3151,7 @@
                         only_block = False
                         break
                 if only_block:
-                    end_log, end = find_le(start_lines, end - 1)
+                    (end_log, end) = find_le(start_lines, end - 1)
                 continue
 
             source = local_fix(source, start_log, end_log,
@@ -3153,45 +3192,54 @@
     parser.add_argument('-v', '--verbose', action='count', dest='verbose',
                         default=0,
                         help='print verbose messages; '
-                        'multiple -v result in more verbose messages')
+                             'multiple -v result in more verbose messages')
     parser.add_argument('-d', '--diff', action='store_true', dest='diff',
                         help='print the diff for the fixed source')
     parser.add_argument('-i', '--in-place', action='store_true',
                         help='make changes to files in place')
+    parser.add_argument('--global-config', metavar='filename',
+                        default=DEFAULT_CONFIG,
+                        help='path to a global pep8 config file; if this file '
+                             'does not exist then this is ignored '
+                             '(default: {0})'.format(DEFAULT_CONFIG))
+    parser.add_argument('--ignore-local-config', action='store_true',
+                        help="don't look for and apply local config files; "
+                             'if not passed, defaults are updated with any '
+                             "config files in the project's root directory")
     parser.add_argument('-r', '--recursive', action='store_true',
                         help='run recursively over directories; '
-                        'must be used with --in-place or --diff')
+                             'must be used with --in-place or --diff')
     parser.add_argument('-j', '--jobs', type=int, metavar='n', default=1,
                         help='number of parallel jobs; '
-                        'match CPU count if value is less than 1')
+                             'match CPU count if value is less than 1')
     parser.add_argument('-p', '--pep8-passes', metavar='n',
                         default=-1, type=int,
                         help='maximum number of additional pep8 passes '
-                        '(default: infinite)')
+                             '(default: infinite)')
     parser.add_argument('-a', '--aggressive', action='count', default=0,
                         help='enable non-whitespace changes; '
-                        'multiple -a result in more aggressive changes')
+                             'multiple -a result in more aggressive changes')
     parser.add_argument('--experimental', action='store_true',
                         help='enable experimental fixes')
     parser.add_argument('--exclude', metavar='globs',
                         help='exclude file/directory names that match these '
-                        'comma-separated globs')
+                             'comma-separated globs')
     parser.add_argument('--list-fixes', action='store_true',
                         help='list codes for fixes; '
                         'used by --ignore and --select')
     parser.add_argument('--ignore', metavar='errors', default='',
                         help='do not fix these errors/warnings '
-                        '(default: {0})'.format(DEFAULT_IGNORE))
+                             '(default: {0})'.format(DEFAULT_IGNORE))
     parser.add_argument('--select', metavar='errors', default='',
                         help='fix only these errors/warnings (e.g. E4,W)')
     parser.add_argument('--max-line-length', metavar='n', default=79, type=int,
                         help='set maximum allowed line length '
-                        '(default: %(default)s)')
+                             '(default: %(default)s)')
     parser.add_argument('--range', metavar='line', dest='line_range',
                         default=None, type=int, nargs=2,
                         help='only fix errors found within this inclusive '
-                        'range of line numbers (e.g. 1 99); '
-                        'line numbers are indexed at 1')
+                             'range of line numbers (e.g. 1 99); '
+                             'line numbers are indexed at 1')
     parser.add_argument('--indent-size', default=DEFAULT_INDENT_SIZE,
                         type=int, metavar='n',
                         help='number of spaces per indent level '
@@ -3202,7 +3250,7 @@
     return parser
 
 
-def parse_args(arguments):
+def parse_args(arguments, apply_config=False):
     """Parse command-line options."""
     parser = create_parser()
     args = parser.parse_args(arguments)
@@ -3212,6 +3260,11 @@
 
     args.files = [decode_filename(name) for name in args.files]
 
+    if apply_config:
+        parser = read_config(args, parser)
+        args = parser.parse_args(arguments)
+        args.files = [decode_filename(name) for name in args.files]
+
     if '-' in args.files:
         if len(args.files) > 1:
             parser.error('cannot mix stdin and regular files')
@@ -3243,19 +3296,19 @@
         parser.error('--max-line-length must be greater than 0')
 
     if args.select:
-        args.select = args.select.split(',')
+        args.select = _split_comma_separated(args.select)
 
     if args.ignore:
-        args.ignore = args.ignore.split(',')
+        args.ignore = _split_comma_separated(args.ignore)
     elif not args.select:
         if args.aggressive:
             # Enable everything by default if aggressive.
             args.select = ['E', 'W']
         else:
-            args.ignore = DEFAULT_IGNORE.split(',')
+            args.ignore = _split_comma_separated(DEFAULT_IGNORE)
 
     if args.exclude:
-        args.exclude = args.exclude.split(',')
+        args.exclude = _split_comma_separated(args.exclude)
     else:
         args.exclude = []
 
@@ -3278,6 +3331,44 @@
     return args
 
 
+def read_config(args, parser):
+    """Read both user configuration and local configuration."""
+    try:
+        from configparser import ConfigParser as SafeConfigParser
+        from configparser import Error
+    except ImportError:
+        from ConfigParser import SafeConfigParser
+        from ConfigParser import Error
+
+    config = SafeConfigParser()
+
+    try:
+        config.read(args.global_config)
+
+        if not args.ignore_local_config:
+            parent = tail = args.files and os.path.abspath(
+                os.path.commonprefix(args.files))
+            while tail:
+                if config.read([os.path.join(parent, fn)
+                                for fn in PROJECT_CONFIG]):
+                    break
+                (parent, tail) = os.path.split(parent)
+
+        defaults = dict((k.lstrip('-').replace('-', '_'), v)
+                        for k, v in config.items('pep8'))
+        parser.set_defaults(**defaults)
+    except Error:
+        # Ignore for now.
+        pass
+
+    return parser
+
+
+def _split_comma_separated(string):
+    """Return a set of strings."""
+    return set(filter(None, string.split(',')))
+
+
 def decode_filename(filename):
     """Return Unicode filename."""
     if isinstance(filename, unicode):
@@ -3519,6 +3610,8 @@
     for pattern in exclude:
         if fnmatch.fnmatch(base_name, pattern):
             return False
+        if fnmatch.fnmatch(filename, pattern):
+            return False
 
     if not os.path.isdir(filename) and not is_python_file(filename):
         return False
@@ -3600,7 +3693,19 @@
     )
 
 
-def main():
+def wrap_output(output, encoding):
+    """Return output with specified encoding."""
+    return codecs.getwriter(encoding)(output.buffer
+                                      if hasattr(output, 'buffer')
+                                      else output)
+
+
+def get_encoding():
+    """Return preferred encoding."""
+    return locale.getpreferredencoding() or sys.getdefaultencoding()
+
+
+def main(apply_config=True):
     """Tool main."""
     try:
         # Exit on broken pipe.
@@ -3610,7 +3715,7 @@
         pass
 
     try:
-        args = parse_args(sys.argv[1:])
+        args = parse_args(sys.argv[1:], apply_config=apply_config)
 
         if args.list_fixes:
             for code, description in sorted(supported_fixes()):
@@ -3621,9 +3726,12 @@
         if args.files == ['-']:
             assert not args.in_place
 
+            encoding = sys.stdin.encoding or get_encoding()
+
             # LineEndingWrapper is unnecessary here due to the symmetry between
             # standard in and standard out.
-            sys.stdout.write(fix_code(sys.stdin.read(), args))
+            wrap_output(sys.stdout, encoding=encoding).write(
+                fix_code(sys.stdin.read(), args, encoding=encoding))
         else:
             if args.in_place or args.diff:
                 args.files = list(set(args.files))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/setup.cfg new/autopep8-1.1.1/setup.cfg
--- old/autopep8-1.0.3/setup.cfg        2014-06-10 14:47:48.000000000 +0200
+++ new/autopep8-1.1.1/setup.cfg        2015-02-26 06:58:32.000000000 +0100
@@ -1,3 +1,6 @@
+[bdist_wheel]
+universal = 1
+
 [egg_info]
 tag_build = 
 tag_date = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/test/fake_configuration/.pep8 
new/autopep8-1.1.1/test/fake_configuration/.pep8
--- old/autopep8-1.0.3/test/fake_configuration/.pep8    1970-01-01 
01:00:00.000000000 +0100
+++ new/autopep8-1.1.1/test/fake_configuration/.pep8    2014-12-25 
03:20:09.000000000 +0100
@@ -0,0 +1,2 @@
+[pep8]
+indent-size=2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.0.3/test/test_autopep8.py 
new/autopep8-1.1.1/test/test_autopep8.py
--- old/autopep8-1.0.3/test/test_autopep8.py    2014-06-10 14:41:58.000000000 
+0200
+++ new/autopep8-1.1.1/test/test_autopep8.py    2015-02-26 06:38:55.000000000 
+0100
@@ -1,6 +1,15 @@
 #!/usr/bin/env python
 # coding: utf-8
 
+"""Test suite for autopep8.
+
+Unit tests go in "UnitTests". System tests go in "SystemTests".
+
+"""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
 from __future__ import unicode_literals
 
 import os
@@ -32,6 +41,9 @@
 import autopep8
 
 
+FAKE_CONFIGURATION = os.path.join(ROOT_DIR, 'test', 'fake_configuration')
+
+
 if 'AUTOPEP8_COVERAGE' in os.environ and int(os.environ['AUTOPEP8_COVERAGE']):
     AUTOPEP8_CMD_TUPLE = ('coverage', 'run', '--branch', '--parallel',
                           '--omit=*/site-packages/*',
@@ -201,6 +213,10 @@
             '# abc',
             autopep8.fix_e265('##   #   ##abc'))
 
+        self.assertEqual(
+            '# abc "# noqa"',
+            autopep8.fix_e265('# abc "# noqa"'))
+
     def test_format_block_comments_should_leave_outline_alone(self):
         line = """\
 ###################################################################
@@ -412,6 +428,41 @@
             self.assertTrue(autopep8.match_file(filename, exclude=[]),
                             msg=filename)
 
+    def test_find_files(self):
+        temp_directory = tempfile.mkdtemp()
+        try:
+            target = os.path.join(temp_directory, 'dir')
+            os.mkdir(target)
+            with open(os.path.join(target, 'a.py'), 'w'):
+                pass
+
+            exclude = os.path.join(target, 'ex')
+            os.mkdir(exclude)
+            with open(os.path.join(exclude, 'b.py'), 'w'):
+                pass
+
+            sub = os.path.join(exclude, 'sub')
+            os.mkdir(sub)
+            with open(os.path.join(sub, 'c.py'), 'w'):
+                pass
+
+            # FIXME: Avoid changing directory. This may interfere with parallel
+            # test runs.
+            cwd = os.getcwd()
+            os.chdir(temp_directory)
+            try:
+                files = list(autopep8.find_files(
+                    ['dir'], True, [os.path.join('dir', 'ex')]))
+            finally:
+                os.chdir(cwd)
+
+            file_names = [os.path.basename(f) for f in files]
+            self.assertIn('a.py', file_names)
+            self.assertNotIn('b.py', file_names)
+            self.assertNotIn('c.py', file_names)
+        finally:
+            shutil.rmtree(temp_directory)
+
     def test_line_shortening_rank(self):
         self.assertGreater(
             autopep8.line_shortening_rank('(1\n+1)\n',
@@ -964,6 +1015,7 @@
         # report properly, the below command will take a long time.
         p = Popen(list(AUTOPEP8_CMD_TUPLE) +
                   ['-vvv', '--select=E101', '--diff',
+                   '--global-config={0}'.format(os.devnull),
                    os.path.join(ROOT_DIR, 'test', 'e101_example.py')],
                   stdout=PIPE, stderr=PIPE)
         output = [x.decode('utf-8') for x in p.communicate()][0]
@@ -2039,12 +2091,36 @@
         with autopep8_context(line) as result:
             self.assertEqual(fixed, result)
 
+    def test_not_e301_extended_with_comment(self):
+        line = '''\
+class Foo(object):
+
+    """Test."""
+
+    # A comment.
+    def foo(self):
+        pass
+'''
+        with autopep8_context(line) as result:
+            self.assertEqual(line, result)
+
     def test_e302(self):
         line = 'def f():\n    print 1\n\ndef ff():\n    print 2\n'
         fixed = 'def f():\n    print 1\n\n\ndef ff():\n    print 2\n'
         with autopep8_context(line) as result:
             self.assertEqual(fixed, result)
 
+    def test_e302_bug(self):
+        """Avoid creating bad syntax."""
+        line = r"""def repeatable_expr():      return [bracketed_choice, 
simple_match, rule_ref],\
+                                    Optional(repeat_operator)
+# def match():                return [simple_match , mixin_rule_match] TODO
+def simple_match():         return [str_match, re_match]
+"""
+        self.assertTrue(autopep8.check_syntax(line))
+        with autopep8_context(line) as result:
+            self.assertTrue(autopep8.check_syntax(result))
+
     def test_e303(self):
         line = '\n\n\n# alpha\n\n1\n'
         fixed = '\n\n# alpha\n\n1\n'
@@ -2077,11 +2153,31 @@
             self.assertEqual(fixed, result)
 
     def test_e309(self):
-        line = 'class Foo:\n    def bar():\n        print 1\n'
-        fixed = 'class Foo:\n\n    def bar():\n        print 1\n'
+        line = """
+class Foo:
+    def bar():
+        print 1
+"""
+        fixed = """
+class Foo:
+
+    def bar():
+        print 1
+"""
         with autopep8_context(line) as result:
             self.assertEqual(fixed, result)
 
+    def test_not_e309_with_comment(self):
+        line = """
+class Foo:
+
+    # A comment.
+    def bar():
+        print 1
+"""
+        with autopep8_context(line) as result:
+            self.assertEqual(line, result)
+
     def test_e401(self):
         line = 'import os, sys\n'
         fixed = 'import os\nimport sys\n'
@@ -2130,6 +2226,34 @@
         with autopep8_context(line) as result:
             self.assertEqual(fixed, result)
 
+    def test_e501_with_in(self):
+        line = """\
+if True:
+    if True:
+        if True:
+            if True:
+                if True:
+                    if True:
+                        if True:
+                            if True:
+                                if k_left in ('any', k_curr) and k_right in 
('any', k_curr):
+                                    pass
+"""
+        fixed = """\
+if True:
+    if True:
+        if True:
+            if True:
+                if True:
+                    if True:
+                        if True:
+                            if True:
+                                if k_left in ('any', k_curr) and k_right in 
('any', k_curr):
+                                    pass
+"""
+        with autopep8_context(line) as result:
+            self.assertEqual(fixed, result)
+
     def test_e501_with_commas_and_colons(self):
         line = """\
 foobar = {'aaaaaaaaaaaa': 'bbbbbbbbbbbbbbbb', 'dddddd': 'eeeeeeeeeeeeeeee', 
'ffffffffffff': 'gggggggg'}
@@ -3261,6 +3385,38 @@
         with autopep8_context(line, options=['-aa']) as result:
             self.assertEqual(fixed, result)
 
+    def test_e501_for_line_over_limit(self):
+        line = """\
+for aaaaaaaaa in xxxxxxxxxxxx(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, 
cccccccccccccc, dddddddddddddddddddddd):
+    pass
+"""
+        fixed = """\
+for aaaaaaaaa in xxxxxxxxxxxx(
+        aaaaaaaaaaaaaaaaaa,
+        bbbbbbbbbbbbbbbb,
+        cccccccccccccc,
+        dddddddddddddddddddddd):
+    pass
+"""
+        with autopep8_context(line, options=['-aa']) as result:
+            self.assertEqual(fixed, result)
+
+    def test_e501_while_line_over_limit(self):
+        line = """\
+while xxxxxxxxxxxx(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, cccccccccccccc, 
dddddddddddddddddddddd):
+    pass
+"""
+        fixed = """\
+while xxxxxxxxxxxx(
+        aaaaaaaaaaaaaaaaaa,
+        bbbbbbbbbbbbbbbb,
+        cccccccccccccc,
+        dddddddddddddddddddddd):
+    pass
+"""
+        with autopep8_context(line, options=['-aa']) as result:
+            self.assertEqual(fixed, result)
+
     def test_e502(self):
         line = "print('abc'\\\n      'def')\n"
         fixed = "print('abc'\n      'def')\n"
@@ -3417,6 +3573,12 @@
         with autopep8_context(line) as result:
             self.assertEqual(fixed, result)
 
+    def test_e703_with_inline_comment(self):
+        line = 'a = 5;    # inline comment\n'
+        fixed = 'a = 5    # inline comment\n'
+        with autopep8_context(line) as result:
+            self.assertEqual(fixed, result)
+
     def test_e711(self):
         line = 'foo == None\n'
         fixed = 'foo is None\n'
@@ -3512,6 +3674,19 @@
         with autopep8_context(line, options=['--aggressive']) as result:
             self.assertEqual(fixed, result)
 
+    def test_e901_should_cause_indentation_screw_up(self):
+        line = """\
+def tmp(g):
+    g(4)))
+
+    if not True:
+        pass
+        pass
+"""
+
+        with autopep8_context(line) as result:
+            self.assertEqual(line, result)
+
     def test_should_preserve_vertical_tab(self):
         line = """\
 #Memory Bu\vffer Register:
@@ -3884,6 +4059,7 @@
         with autopep8_context(line, options=['--aggressive']) as result:
             self.assertEqual(line, result)
 
+    # FIXME: These tests should use multiline strings for readability.
     def test_range(self):
         line = 'print( 1 )\nprint( 2 )\n print( 3 )\n'
         fixed = 'print( 1 )\nprint(2)\n print( 3 )\n'
@@ -4010,6 +4186,44 @@
         with autopep8_context(line, options=['--range', '2', '7']) as result:
             self.assertEqual(fixed_2_7, result)
 
+    def test_range_indent_multiline_strings_and_docstring(self):
+        code_ = '''
+def f():
+  """docstring
+  continued"""
+  a = """multi
+line
+string"""
+  #comment
+  a=1
+a=2
+'''
+        fixed_2_7 = '''
+def f():
+    """docstring
+    continued"""
+    a = """multi
+line
+string"""
+    # comment
+    a = 1
+a=2
+'''
+        with autopep8_context(code_, options=['--range', '2', '9']) as result:
+            self.assertEqual(fixed_2_7, result)
+
+    def test_range_with_indented_comments(self):
+        code_ = 'if True:\n  if True:\n    if True:\n      # bah\n      pass\n'
+        fixed = 'if True:\n  if True:\n    if True:\n        # bah\n        
pass\n'
+        with autopep8_context(code_, options=['--range', '4', '5']) as result:
+            self.assertEqual(fixed, result)
+
+    def test_range_with_indented_comments_spaced(self):
+        code_ = 'if True:\n  if True:\n    if True:\n      # bah\n\n      
pass\n'
+        fixed = 'if True:\n  if True:\n    if True:\n        # bah\n\n        
pass\n'
+        with autopep8_context(code_, options=['--range', '4', '6']) as result:
+            self.assertEqual(fixed, result)
+
     def test_range_with_broken_syntax(self):
         line = """\
 if True:
@@ -4059,6 +4273,12 @@
         with autopep8_subprocess(line, ['--ignore=E,W']) as result:
             self.assertEqual(line, result)
 
+    def test_pep8_ignore_should_handle_trailing_comma_gracefully(self):
+        line = "'abc'  \n"
+        fixed = "'abc'\n"
+        with autopep8_subprocess(line, ['--ignore=,']) as result:
+            self.assertEqual(fixed, result)
+
     def test_help(self):
         p = Popen(list(AUTOPEP8_CMD_TUPLE) + ['-h'],
                   stdout=PIPE)
@@ -4300,6 +4520,77 @@
             process.communicate(line.encode('utf-8'))[0].decode('utf-8'))
 
 
+class ConfigurationTests(unittest.TestCase):
+
+    def test_local_config(self):
+        args = autopep8.parse_args(
+            [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+             '--global-config={0}'.format(os.devnull)],
+            apply_config=True)
+        self.assertEqual(args.indent_size, 2)
+
+    def test_config_override(self):
+        args = autopep8.parse_args(
+            [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+             '--indent-size=7'],
+            apply_config=True)
+        self.assertEqual(args.indent_size, 7)
+
+    def test_config_false_with_local(self):
+        args = autopep8.parse_args(
+            [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+             '--global-config=False'],
+            apply_config=True)
+        self.assertEqual(args.global_config, 'False')
+        self.assertEqual(args.indent_size, 2)
+
+    def test_config_false_with_local_space(self):
+        args = autopep8.parse_args(
+            [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+             '--global-config', 'False'],
+            apply_config=True)
+        self.assertEqual(args.global_config, 'False')
+        self.assertEqual(args.indent_size, 2)
+
+    def test_config_false_with_local_autocomplete(self):
+        args = autopep8.parse_args(
+            [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+             '--g', 'False'],
+            apply_config=True)
+        self.assertEqual(args.global_config, 'False')
+        self.assertEqual(args.indent_size, 2)
+
+    def test_config_false_without_local(self):
+        args = autopep8.parse_args(['/nowhere/foo.py',
+                                    '--global-config={0}'.format(os.devnull)],
+                                   apply_config=True)
+        self.assertEqual(args.indent_size, 4)
+
+    def test_global_config_with_locals(self):
+        with temporary_file_context('[pep8]\nindent-size=3\n') as filename:
+            args = autopep8.parse_args(
+                [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+                 '--global-config={0}'.format(filename)],
+                apply_config=True)
+            self.assertEqual(args.indent_size, 2)
+
+    def test_global_config_ignore_locals(self):
+        with temporary_file_context('[pep8]\nindent-size=3\n') as filename:
+            args = autopep8.parse_args(
+                [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+                 '--global-config={0}'.format(filename),
+                 '--ignore-local-config'],
+                apply_config=True)
+            self.assertEqual(args.indent_size, 3)
+
+    def test_global_config_without_locals(self):
+        with temporary_file_context('[pep8]\nindent-size=3\n') as filename:
+            args = autopep8.parse_args(
+                ['/nowhere/foo.py', '--global-config={0}'.format(filename)],
+                apply_config=True)
+            self.assertEqual(args.indent_size, 3)
+
+
 class ExperimentalSystemTests(unittest.TestCase):
 
     maxDiff = None
@@ -4344,7 +4635,8 @@
         with autopep8_context(line, options=['--experimental']) as result:
             self.assertEqual(fixed, result)
 
-    def 
test_e501_experimental_with_inline_comments_should_skip_multiline(self):
+    def test_e501_experimental_with_inline_comments_should_skip_multiline(
+            self):
         line = """\
 '''This should be left alone. 
-----------------------------------------------------
 
@@ -4388,7 +4680,8 @@
         with autopep8_context(line, options=['--experimental']) as result:
             self.assertEqual(line, result)
 
-    def 
test_e501_experimental_with_inline_comments_should_skip_edge_cases(self):
+    def test_e501_experimental_with_inline_comments_should_skip_edge_cases(
+            self):
         line = """\
 if True:
     x = \\
@@ -4503,7 +4796,8 @@
                                              '--experimental']) as result:
             self.assertEqual(fixed, result)
 
-    def 
test_e501_experimental_should_not_try_to_break_at_every_paren_in_arithmetic(self):
+    def 
test_e501_experimental_should_not_try_to_break_at_every_paren_in_arithmetic(
+            self):
         line = """\
 term3 = w6 * c5 * (8.0 * psi4 * (11.0 - 24.0 * t2) - 28 * psi3 * (1 - 6.0 * 
t2) + psi2 * (1 - 32 * t2) - psi * (2.0 * t2) + t4) / 720.0
 this_should_be_shortened = ('                                                  
               ', '            ')
@@ -5141,7 +5435,8 @@
         with autopep8_context(line, options=['--experimental']) as result:
             self.assertEqual(fixed, result)
 
-    def 
test_e501_experimental_avoid_breaking_at_empty_parentheses_if_possible(self):
+    def test_e501_experimental_avoid_breaking_at_empty_parentheses_if_possible(
+            self):
         line = """\
 someverylongindenttionwhatnot().foo().bar().baz("and here is a long string 
123456789012345678901234567890")
 """
@@ -5537,6 +5832,64 @@
 """
         with autopep8_context(line, options=['--experimental']) as result:
             self.assertEqual(fixed, result)
+
+    def test_e501_experimental_for_line_over_limit(self):
+        line = """\
+for aaaaaaaaa in xxxxxxxxxxxx(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, 
cccccccccccccc, dddddddddddddddddddddd):
+    pass
+"""
+        fixed = """\
+for aaaaaaaaa in xxxxxxxxxxxx(
+        aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, cccccccccccccc,
+        dddddddddddddddddddddd):
+    pass
+"""
+        with autopep8_context(line, options=['--experimental']) as result:
+            self.assertEqual(fixed, result)
+
+    def test_e501_experimental_while_line_over_limit(self):
+        line = """\
+while xxxxxxxxxxxx(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, cccccccccccccc, 
dddddddddddddddddddddd):
+    pass
+"""
+        fixed = """\
+while xxxxxxxxxxxx(
+        aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, cccccccccccccc,
+        dddddddddddddddddddddd):
+    pass
+"""
+        with autopep8_context(line, options=['--experimental']) as result:
+            self.assertEqual(fixed, result)
+
+    def test_e501_experimental_with_in(self):
+        line = """\
+if True:
+    if True:
+        if True:
+            if True:
+                if True:
+                    if True:
+                        if True:
+                            if True:
+                                if k_left in ('any', k_curr) and k_right in 
('any', k_curr):
+                                    pass
+"""
+        fixed = """\
+if True:
+    if True:
+        if True:
+            if True:
+                if True:
+                    if True:
+                        if True:
+                            if True:
+                                if k_left in (
+                                        'any', k_curr) and k_right in (
+                                        'any', k_curr):
+                                    pass
+"""
+        with autopep8_context(line, options=['--experimental']) as result:
+            self.assertEqual(fixed, result)
 
 
 @contextlib.contextmanager


Reply via email to