Hello community, here is the log from the commit of package python3-autopep8 for openSUSE:Factory checked in at 2014-12-16 14:48:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-autopep8 (Old) and /work/SRC/openSUSE:Factory/.python3-autopep8.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-autopep8" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-autopep8/python3-autopep8.changes 2014-11-18 22:45:21.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python3-autopep8.new/python3-autopep8.changes 2014-12-16 14:49:01.000000000 +0100 @@ -1,0 +2,26 @@ +Thu Dec 11 05:38:47 UTC 2014 - a...@gmx.de + +- update to version 1.0.4: + * Avoid extended E301 false positive + * Avoid E309 false positive + * Support W293 + * Support selecting E111 + * Handle trailing commas gracefully in "--ignore" + * Clean up + * Move "ws_comma" fixer to global fixes + * Format + * Pass in filename to lib2to3 + * Simplify + * Simplify + * Write to "sys.stdout" with desired encoding + * Use '--experimental' for experimental tests. + * Normalize 'for' and 'while' constructs so that they can be reformatted properly. + * Document + * Switch to development mode + * Document "encoding" parameter + * Give credit for patch + * Fix whitespace + * Fixed issue where the encoding was not correct when the contents of the file were passed directly a + * ignore idea(for pycharm) + +------------------------------------------------------------------- Old: ---- autopep8-1.0.3.tar.gz New: ---- autopep8-1.0.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-autopep8.spec ++++++ --- /var/tmp/diff_new_pack.613lJ6/_old 2014-12-16 14:49:03.000000000 +0100 +++ /var/tmp/diff_new_pack.613lJ6/_new 2014-12-16 14:49:03.000000000 +0100 @@ -17,7 +17,7 @@ Name: python3-autopep8 -Version: 1.0.3 +Version: 1.0.4 Release: 0 Url: https://github.com/hhatto/autopep8 Summary: Automatic generated to pep8 checked code ++++++ autopep8-1.0.3.tar.gz -> autopep8-1.0.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.0.3/AUTHORS.rst new/autopep8-1.0.4/AUTHORS.rst --- old/autopep8-1.0.3/AUTHORS.rst 2014-03-29 15:23:30.000000000 +0100 +++ new/autopep8-1.0.4/AUTHORS.rst 2014-07-30 18:41:37.000000000 +0200 @@ -19,3 +19,4 @@ - Christopher Medrela (https://github.com/chrismedrela) - 小明 (https://github.com/dongweiming) - Andy Hayden (https://github.com/hayd) +- Fabio Zadrozny (https://github.com/fabioz) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.0.3/PKG-INFO new/autopep8-1.0.4/PKG-INFO --- old/autopep8-1.0.3/PKG-INFO 2014-06-10 14:47:48.000000000 +0200 +++ new/autopep8-1.0.4/PKG-INFO 2014-09-09 19:07:39.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: autopep8 -Version: 1.0.3 +Version: 1.0.4 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.0.3/autopep8.egg-info/PKG-INFO new/autopep8-1.0.4/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.0.4/autopep8.egg-info/PKG-INFO 2014-09-09 19:07:39.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: autopep8 -Version: 1.0.3 +Version: 1.0.4 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.0.3/autopep8.egg-info/requires.txt new/autopep8-1.0.4/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.0.4/autopep8.egg-info/requires.txt 2014-09-09 19:07:39.000000000 +0200 @@ -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.0.4/autopep8.py --- old/autopep8-1.0.3/autopep8.py 2014-06-10 14:45:35.000000000 +0200 +++ new/autopep8-1.0.4/autopep8.py 2014-09-09 19:06:54.000000000 +0200 @@ -67,7 +67,7 @@ unicode = str -__version__ = '1.0.3' +__version__ = '1.0.4' 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'], @@ -148,6 +149,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 +158,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 +168,7 @@ if ( indent_level and not blank_lines and + not blank_before and logical_line.startswith(('def ')) and '(self' in logical_line ): @@ -441,8 +444,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 +643,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'] @@ -1014,10 +1005,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] @@ -1186,7 +1174,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 +1183,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 +1206,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 +1217,8 @@ return refactor(source, code_to_2to3(select=select, - ignore=ignore)) + ignore=ignore), + filename=filename) def fix_w602(source, aggressive=True): @@ -2372,7 +2363,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 +2603,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 +2615,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 @@ -2815,13 +2807,17 @@ return True -def fix_code(source, options=None): - """Return fixed source code.""" +def fix_code(source, options=None, encoding=None): + """Return fixed source code. + + "encoding" will be used to decode "source" if it is a byte string. + + """ if not options: options = parse_args(['']) if not isinstance(source, unicode): - source = source.decode(locale.getpreferredencoding()) + source = source.decode(encoding or locale.getpreferredencoding()) sio = io.StringIO(source) return fix_lines(sio.readlines(), options=options) @@ -2841,7 +2837,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() @@ -2878,11 +2876,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 +2915,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 +2939,8 @@ source = fix_2to3(source, aggressive=options.aggressive, select=options.select, - ignore=options.ignore) + ignore=options.ignore, + filename=filename) return source @@ -3078,8 +3074,8 @@ 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. + # Start shares indent up to n. if n <= end: source = local_fix(source, start_log, n_log, start_lines, end_lines, @@ -3098,7 +3094,7 @@ if (indents[after_end_log] == indents[start_log] and is_continued_stmt(source[after_end])): - # find n, the beginning of the last continued statement + # 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]: @@ -3243,19 +3239,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 +3274,11 @@ return args +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): @@ -3600,6 +3601,13 @@ ) +def wrap_output(output, encoding): + """Return output with specified encoding.""" + return codecs.getwriter(encoding)(output.buffer + if hasattr(output, 'buffer') + else output) + + def main(): """Tool main.""" try: @@ -3621,9 +3629,12 @@ if args.files == ['-']: assert not args.in_place + encoding = sys.stdin.encoding or locale.getpreferredencoding() + # 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/test/test_autopep8.py new/autopep8-1.0.4/test/test_autopep8.py --- old/autopep8-1.0.3/test/test_autopep8.py 2014-06-10 14:41:58.000000000 +0200 +++ new/autopep8-1.0.4/test/test_autopep8.py 2014-09-09 19:03:42.000000000 +0200 @@ -1,6 +1,12 @@ #!/usr/bin/env python # coding: utf-8 +"""Test suite for autopep8. + +Unit tests go in "UnitTests". System tests go in "SystemTests". + +""" + from __future__ import unicode_literals import os @@ -2039,6 +2045,19 @@ 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' @@ -2077,11 +2096,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' @@ -3261,6 +3300,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" @@ -4059,6 +4130,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) @@ -5537,6 +5614,34 @@ """ 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) @contextlib.contextmanager -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org