From 21677bde455fdc08553630ee2abe4fc678351a61 Mon Sep 17 00:00:00 2001 From: Steve Lacy Date: Wed, 2 Mar 2011 14:37:23 -0800 Subject: [PATCH 01/25] Use /usr/bin/env python instead of straight /usr/bin/python This change makes the pep8 executable function properly when running under a virtualenv or zc.buildout environment, which will have a special version of python on the path that internally changes its PYTHONPATH to include special libraries and modules. --- pep8.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep8.py b/pep8.py index 227a9a3a..6cd81016 100755 --- a/pep8.py +++ b/pep8.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # pep8.py - Check Python source code formatting, according to PEP 8 # Copyright (C) 2006 Johann C. Rocholl # From 7aa224f96f9d316828701b9fb675e756f0855d7e Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Mon, 13 Dec 2010 16:47:48 -0800 Subject: [PATCH 02/25] add max-line-length option --- pep8.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pep8.py b/pep8.py index 227a9a3a..6afe6bc3 100755 --- a/pep8.py +++ b/pep8.py @@ -242,7 +242,7 @@ def maximum_line_length(physical_line): """ 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 @@ -250,8 +250,9 @@ def maximum_line_length(physical_line): 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 ############################################################################## @@ -1289,6 +1290,10 @@ def process_options(arglist=None): 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) From 1c28dc0c0ca4eb9d41730833d486d2eab5e07e61 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Tue, 25 Jan 2011 19:28:44 -0800 Subject: [PATCH 03/25] Added max-line-length argument to README --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index e8ad376f..0087d66a 100644 --- a/README.rst +++ b/README.rst @@ -109,6 +109,7 @@ Quick help is available on the command line:: error and set exit code to 1 if total is not null --benchmark measure processing speed --testsuite=dir run regression tests from dir + --max-line-length=n set to a higher value to relax pep8 line length --doctest run doctest on myself Feedback From 1ba88426dd0d60c4d2ccc1543ec0870aab2b9cf0 Mon Sep 17 00:00:00 2001 From: fabioz Date: Thu, 9 Feb 2012 13:12:53 -0200 Subject: [PATCH 04/25] Fixed issue when line decoding failed on Jython 2.2.1 (UnicodeDecodeError does not exist in Jython 2.2.1 and a UnicodeError is raised instead). --- pep8.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pep8.py b/pep8.py index 227a9a3a..6ec0ae75 100755 --- a/pep8.py +++ b/pep8.py @@ -108,6 +108,11 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) except NameError: from sets import ImmutableSet as frozenset +#Fix to work on Jython 2.2.1 +try: + UnicodeDecodeError +except NameError: + UnicodeDecodeError = UnicodeError DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git' DEFAULT_IGNORE = 'E24' From e7c34145ca57fcccdb44cbc6c0f4adbf3df7590f Mon Sep 17 00:00:00 2001 From: fabioz Date: Tue, 21 Feb 2012 21:49:24 -0200 Subject: [PATCH 05/25] Pre-compiling lambda regexp (Jython has an issue when the re module is imported in one thread and used in another). --- pep8.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pep8.py b/pep8.py index 6ec0ae75..f628c00a 100755 --- a/pep8.py +++ b/pep8.py @@ -128,7 +128,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]') WHITESPACE_AROUND_NAMED_PARAMETER_REGEX = \ re.compile(r'[()]|\s=[^=]|[^=!<>]=\s') - +LAMBDA_REGEX = re.compile(r'\blambda\b') WHITESPACE = ' \t' @@ -661,7 +661,7 @@ def compound_statements(logical_line): before = line[:found] if (before.count('{') <= before.count('}') and # {'a': 1} (dict) before.count('[') <= before.count(']') and # [1:2] (slice) - not re.search(r'\blambda\b', before)): # lambda x: x + not LAMBDA_REGEX.search(before)): # lambda x: x return found, "E701 multiple statements on one line (colon)" found = line.find(';') if -1 < found: From f7beff026472f67c9434e9d6f8f9fea2b0964395 Mon Sep 17 00:00:00 2001 From: clayg Date: Thu, 1 Mar 2012 22:36:44 -0600 Subject: [PATCH 06/25] test for issue34 --- testsuite/W60.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/W60.py b/testsuite/W60.py index 19b65494..67e04364 100644 --- a/testsuite/W60.py +++ b/testsuite/W60.py @@ -3,6 +3,8 @@ print a #: W602 raise DummyError, "Message" +#: Okay +raise t, v, tb #: W603 if x <> 0: x = 0 From c7730e14159b0c171a08871db467073bc85e0442 Mon Sep 17 00:00:00 2001 From: clayg Date: Thu, 1 Mar 2012 22:37:12 -0600 Subject: [PATCH 07/25] fix for issue34 --- pep8.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pep8.py b/pep8.py index 227a9a3a..1d25e8cd 100755 --- a/pep8.py +++ b/pep8.py @@ -115,6 +115,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) INDENT_REGEX = re.compile(r'([ \t]*)') RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*(,)') +RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w\s*,\s*\w\s*,\s*\w') SELFTEST_REGEX = re.compile(r'(Okay|[EW]\d{3}):\s(.*)') ERRORCODE_REGEX = re.compile(r'[EW]\d{3}') DOCSTRING_REGEX = re.compile(r'u?r?["\']') @@ -687,7 +688,7 @@ def python_3000_raise_comma(logical_line): form will be removed in Python 3000. """ match = RAISE_COMMA_REGEX.match(logical_line) - if match: + if match and not RERAISE_COMMA_REGEX.match(logical_line): return match.start(1), "W602 deprecated form of raising exception" From cba8f177ed560d25cebad65e86850d9c96c95b78 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 02:09:51 +0200 Subject: [PATCH 08/25] Merge fixes for issues #34, #43 and #48. --- CHANGES.txt | 16 ++++++++++++++++ pep8.py | 5 ++--- setup.py | 16 +++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4934a468..035d4035 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,22 @@ Changelog ========= +0.6.2 UNRELEASED +---------------- + +* Add PyPI classifiers. (Issue #43) + +* Fix the ``--exclude``option. (Issue #48) + +* Fix W602, accept ``raise`` with 3 arguments. (Issue #34) + + +0.6.1 (2010-10-03) +------------------ + +* Fix inconsistent version numbers. (Issue #21) + + 0.6.0 (2010-09-19) ------------------ diff --git a/pep8.py b/pep8.py index 1d25e8cd..059c85e3 100755 --- a/pep8.py +++ b/pep8.py @@ -92,7 +92,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) """ -__version__ = '0.5.1dev' +__version__ = '0.6.2dev' import os import sys @@ -1041,8 +1041,7 @@ def input_dir(dirname, runner=None): if options.verbose: message('directory ' + root) options.counters['directories'] += 1 - dirs.sort() - for subdir in dirs: + for subdir in sorted(dirs): if excluded(subdir): dirs.remove(subdir) files.sort() diff --git a/setup.py b/setup.py index f9d25c4b..8d79d585 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.6.0' +version = '0.6.1' long_description = '\n\n'.join([open('README.rst').read(), open('CHANGES.txt').read(), open('TODO.txt').read()]) @@ -9,7 +9,6 @@ version=version, description="Python style guide checker", long_description=long_description, - classifiers=[], keywords='pep8', author='Johann C. Rocholl', author_email='johann@rocholl.net', @@ -28,4 +27,15 @@ 'pep8 = pep8:_main', ], }, - ) + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], +) From a6edb5f443393cd29ebf88bfa655946e53f779ad Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 02:13:21 +0200 Subject: [PATCH 09/25] Fixes for Jython. --- CHANGES.txt | 2 ++ pep8.py | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 035d4035..d02856cc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,8 @@ Changelog 0.6.2 UNRELEASED ---------------- +* Fixes for Jython. (Issue #49) + * Add PyPI classifiers. (Issue #43) * Fix the ``--exclude``option. (Issue #48) diff --git a/pep8.py b/pep8.py index ae41d212..2200dc78 100755 --- a/pep8.py +++ b/pep8.py @@ -108,12 +108,6 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) except NameError: from sets import ImmutableSet as frozenset -#Fix to work on Jython 2.2.1 -try: - UnicodeDecodeError -except NameError: - UnicodeDecodeError = UnicodeError - DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git' DEFAULT_IGNORE = 'E24' MAX_LINE_LENGTH = 79 @@ -254,7 +248,7 @@ def maximum_line_length(physical_line): if not hasattr(line, 'decode'): # Python 3 line = line.encode('latin-1') length = len(line.decode('utf-8')) - except UnicodeDecodeError: + except UnicodeError: pass if length > MAX_LINE_LENGTH: return MAX_LINE_LENGTH, "E501 line too long (%d characters)" % length From 5fd3056cab62dbc51767676b0ed9bc285e43f228 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 02:56:26 +0200 Subject: [PATCH 10/25] Add the testsuite to MANIFEST.in, add changelog entry for issue #26 too. --- CHANGES.txt | 6 +++++- MANIFEST.in | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index d02856cc..7d00de3c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,11 +5,15 @@ Changelog 0.6.2 UNRELEASED ---------------- +* Make the shebang more flexible. (Issue #26) + +* Add testsuite to the bundle. (Issue #25) + * Fixes for Jython. (Issue #49) * Add PyPI classifiers. (Issue #43) -* Fix the ``--exclude``option. (Issue #48) +* Fix the ``--exclude`` option. (Issue #48) * Fix W602, accept ``raise`` with 3 arguments. (Issue #34) diff --git a/MANIFEST.in b/MANIFEST.in index d40acf71..bdce6571 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ +recursive-include testsuite * include pep8.py include *.txt include *.rst From 3d867ed14dfeca0702e6fb5945790548dde21101 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 03:21:32 +0200 Subject: [PATCH 11/25] Add changelog entry for issue #36 and adapt the help message. --- CHANGES.txt | 2 ++ README.rst | 2 +- pep8.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7d00de3c..d098ed50 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,8 @@ Changelog 0.6.2 UNRELEASED ---------------- +* Allow to specify ``--max-line-length``. (Issue #36) + * Make the shebang more flexible. (Issue #26) * Add testsuite to the bundle. (Issue #25) diff --git a/README.rst b/README.rst index 0087d66a..305547b2 100644 --- a/README.rst +++ b/README.rst @@ -109,7 +109,7 @@ Quick help is available on the command line:: error and set exit code to 1 if total is not null --benchmark measure processing speed --testsuite=dir run regression tests from dir - --max-line-length=n set to a higher value to relax pep8 line length + --max-line-length=n set maximum allowed line length (default 79) --doctest run doctest on myself Feedback diff --git a/pep8.py b/pep8.py index 1c09695b..66fe8486 100755 --- a/pep8.py +++ b/pep8.py @@ -1291,8 +1291,8 @@ def process_options(arglist=None): 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") + help="set maximum allowed line length (default: %d)" % + MAX_LINE_LENGTH) parser.add_option('--doctest', action='store_true', help="run doctest on myself") options, args = parser.parse_args(arglist) From 21c7c9a5acf847f1bf47e9a33b205b783a1ee5ec Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 03:46:12 +0200 Subject: [PATCH 12/25] whitespace bikeshedding. --- pep8.py | 2 ++ setup.py | 67 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/pep8.py b/pep8.py index 66fe8486..60fa8e07 100755 --- a/pep8.py +++ b/pep8.py @@ -108,6 +108,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) except NameError: from sets import ImmutableSet as frozenset + DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git' DEFAULT_IGNORE = 'E24' MAX_LINE_LENGTH = 79 @@ -125,6 +126,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) re.compile(r'[()]|\s=[^=]|[^=!<>]=\s') LAMBDA_REGEX = re.compile(r'\blambda\b') + WHITESPACE = ' \t' BINARY_OPERATORS = frozenset(['**=', '*=', '+=', '-=', '!=', '<>', diff --git a/setup.py b/setup.py index 8d79d585..2c7092d9 100644 --- a/setup.py +++ b/setup.py @@ -5,37 +5,38 @@ open('CHANGES.txt').read(), open('TODO.txt').read()]) -setup(name='pep8', - version=version, - description="Python style guide checker", - long_description=long_description, - keywords='pep8', - author='Johann C. Rocholl', - author_email='johann@rocholl.net', - url='http://github.com/jcrocholl/pep8', - license='Expat license', - py_modules=['pep8'], - namespace_packages=[], - include_package_data=True, - zip_safe=False, - install_requires=[ - 'setuptools', - # -*- Extra requirements: -*- - ], - entry_points={ - 'console_scripts': [ - 'pep8 = pep8:_main', - ], - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], +setup( + name='pep8', + version=version, + description="Python style guide checker", + long_description=long_description, + keywords='pep8', + author='Johann C. Rocholl', + author_email='johann@rocholl.net', + url='http://github.com/jcrocholl/pep8', + license='Expat license', + py_modules=['pep8'], + namespace_packages=[], + include_package_data=True, + zip_safe=False, + install_requires=[ + 'setuptools', + # -*- Extra requirements: -*- + ], + entry_points={ + 'console_scripts': [ + 'pep8 = pep8:_main', + ], + }, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], ) From 65c25cb5e30e6b274522f83548015aa1a3e1d508 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 03:58:03 +0200 Subject: [PATCH 13/25] Change the defaut behaviour to --repeat. --- CHANGES.txt | 4 ++++ README.rst | 3 ++- pep8.py | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d098ed50..fdea6b42 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,10 @@ Changelog 0.6.2 UNRELEASED ---------------- +* Now ``--first`` prints only the first occurence of each error. + The ``--repeat`` flag becomes obsolete because it is the default + behaviour. (Issue #6) + * Allow to specify ``--max-line-length``. (Issue #36) * Make the shebang more flexible. (Issue #26) diff --git a/README.rst b/README.rst index 305547b2..b1bf5a9b 100644 --- a/README.rst +++ b/README.rst @@ -95,7 +95,8 @@ Quick help is available on the command line:: -h, --help show this help message and exit -v, --verbose print status messages, or debug with -vv -q, --quiet report only file names, or nothing with -qq - -r, --repeat show all occurrences of the same error + -r, --repeat (obsolete) show all occurrences of the same error + --first show first occurrence of each error --exclude=patterns exclude files or directories which match these comma separated patterns (default: .svn,CVS,.bzr,.hg,.git) --filename=patterns when parsing directories, only check filenames matching diff --git a/pep8.py b/pep8.py index 60fa8e07..25f00470 100755 --- a/pep8.py +++ b/pep8.py @@ -1263,8 +1263,10 @@ def process_options(arglist=None): 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', '--repeat', action='store_true', - help="show all occurrences of the same error") + parser.add_option('-r', '--repeat', default=True, action='store_true', + help="(obsolete) show all occurrences of the same error") + parser.add_option('--first', action='store_false', dest='repeat', + help="show first occurrence of each error") parser.add_option('--exclude', metavar='patterns', default=DEFAULT_EXCLUDE, help="exclude files or directories which match these " "comma separated patterns (default: %s)" % From 5f70236ce8a70c0af301bbf4e3afd914c1cd1e3d Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 04:08:17 +0200 Subject: [PATCH 14/25] Correctly select all tests if DEFAULT_IGNORE == '' or False. --- CHANGES.txt | 2 ++ pep8.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index fdea6b42..ed22263d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -23,6 +23,8 @@ Changelog * Fix W602, accept ``raise`` with 3 arguments. (Issue #34) +* Correctly select all tests if DEFAULT_IGNORE == ''. + 0.6.1 (2010-10-03) ------------------ diff --git a/pep8.py b/pep8.py index 25f00470..d41160e0 100755 --- a/pep8.py +++ b/pep8.py @@ -1319,7 +1319,7 @@ def process_options(arglist=None): elif options.select: # Ignore all checks which are not explicitly selected options.ignore = [''] - elif options.testsuite or options.doctest: + elif options.testsuite or options.doctest or not DEFAULT_IGNORE: # For doctest and testsuite, all checks are required options.ignore = [] else: From 5a0c9b0bd008bf6ce95b01b4765477a4206d60ab Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 26 Mar 2012 09:01:06 +0200 Subject: [PATCH 15/25] Release version 0.7.0. --- CHANGES.txt | 4 ++-- pep8.py | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ed22263d..ed8f56de 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,8 +2,8 @@ Changelog ========= -0.6.2 UNRELEASED ----------------- +0.7.0 (2012-03-26) +------------------ * Now ``--first`` prints only the first occurence of each error. The ``--repeat`` flag becomes obsolete because it is the default diff --git a/pep8.py b/pep8.py index d41160e0..ce8bb963 100755 --- a/pep8.py +++ b/pep8.py @@ -92,7 +92,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) """ -__version__ = '0.6.2dev' +__version__ = '0.7.0' import os import sys diff --git a/setup.py b/setup.py index 2c7092d9..882c9157 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.6.1' +version = '0.7.0' long_description = '\n\n'.join([open('README.rst').read(), open('CHANGES.txt').read(), open('TODO.txt').read()]) From db3d678e01da0f53ba17c3aa72ff9347efc812d6 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Mon, 26 Mar 2012 11:02:37 +0200 Subject: [PATCH 16/25] ignoring .pyc --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c80c0bab..0428e70a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ pep8.egg-info +*.pyc From c52a3d56b5ed8a60d87865503975fae3a99d402e Mon Sep 17 00:00:00 2001 From: Brian Elliott Date: Thu, 29 Mar 2012 20:13:04 -0500 Subject: [PATCH 17/25] Fix W602 checking of 3 argument raises to handle multi-char names, issue #34 --- pep8.py | 2 +- testsuite/W60.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pep8.py b/pep8.py index ce8bb963..2f9c05c9 100755 --- a/pep8.py +++ b/pep8.py @@ -115,7 +115,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) INDENT_REGEX = re.compile(r'([ \t]*)') RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*(,)') -RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w\s*,\s*\w\s*,\s*\w') +RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,\s*\w+\s*,\s*\w+') SELFTEST_REGEX = re.compile(r'(Okay|[EW]\d{3}):\s(.*)') ERRORCODE_REGEX = re.compile(r'[EW]\d{3}') DOCSTRING_REGEX = re.compile(r'u?r?["\']') diff --git a/testsuite/W60.py b/testsuite/W60.py index 67e04364..ee23d619 100644 --- a/testsuite/W60.py +++ b/testsuite/W60.py @@ -4,7 +4,7 @@ #: W602 raise DummyError, "Message" #: Okay -raise t, v, tb +raise type_, val, tb #: W603 if x <> 0: x = 0 From 431b7e1eef41a8fa809b62677bc933d1030ca337 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Thu, 29 Mar 2012 22:14:42 -0400 Subject: [PATCH 18/25] Replace `message` function with `print` function, since it does the same thing --- pep8.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/pep8.py b/pep8.py index ce8bb963..b50726b6 100755 --- a/pep8.py +++ b/pep8.py @@ -784,13 +784,6 @@ def mute_string(text): return text[:start] + 'x' * (end - start) + text[end:] -def message(text): - """Print a message.""" - # print >> sys.stderr, options.prog + ': ' + text - # print >> sys.stderr, text - print(text) - - ############################################################################## # Framework to run all checks ############################################################################## @@ -999,7 +992,7 @@ def report_error(self, line_number, offset, text, check): if ignore_code(code): return if options.quiet == 1 and not self.file_errors: - message(self.filename) + print(self.filename) if code in options.counters: options.counters[code] += 1 else: @@ -1010,15 +1003,15 @@ def report_error(self, line_number, offset, text, check): return self.file_errors += 1 if options.counters[code] == 1 or options.repeat: - message("%s:%s:%d: %s" % + print("%s:%s:%d: %s" % (self.filename, self.line_offset + line_number, offset + 1, text)) if options.show_source: line = self.lines[line_number - 1] - message(line.rstrip()) - message(' ' * offset + '^') + print(line.rstrip()) + print(' ' * offset + '^') if options.show_pep8: - message(check.__doc__.lstrip('\n').rstrip()) + print(check.__doc__.lstrip('\n').rstrip()) def input_file(filename): @@ -1026,7 +1019,7 @@ def input_file(filename): Run all checks on a Python source file. """ if options.verbose: - message('checking ' + filename) + print('checking ' + filename) errors = Checker(filename).check_all() @@ -1041,7 +1034,7 @@ def input_dir(dirname, runner=None): runner = input_file for root, dirs, files in os.walk(dirname): if options.verbose: - message('directory ' + root) + print('directory ' + root) options.counters['directories'] += 1 for subdir in sorted(dirs): if excluded(subdir): @@ -1189,9 +1182,9 @@ def run_tests(filename): for code in codes: if not options.counters.get(code): errors += 1 - message('%s: error %s not found' % (label, code)) + print('%s: error %s not found' % (label, code)) if options.verbose and not errors: - message('%s: passed (%s)' % (label, ' '.join(codes))) + print('%s: passed (%s)' % (label, ' '.join(codes))) # Keep showing errors for multiple tests reset_counters() # output the real line numbers From 49e8c3111747e57a9893e20c7aa6fac5b83680d2 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Fri, 30 Mar 2012 07:45:37 +0200 Subject: [PATCH 19/25] Add changelog entry for previous fix. --- CHANGES.txt | 6 ++++++ pep8.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index ed8f56de..9ecdab59 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,12 @@ Changelog ========= +0.7.1 UNRELEASED +---------------- + +* Fix W602 ``raise`` to handle multi-char names. (Issue #53) + + 0.7.0 (2012-03-26) ------------------ diff --git a/pep8.py b/pep8.py index 2f9c05c9..dcfd39ce 100755 --- a/pep8.py +++ b/pep8.py @@ -92,7 +92,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) """ -__version__ = '0.7.0' +__version__ = '0.7.1dev' import os import sys From 7aff9d1902702989a98a7b1e636acb04cdbf18a6 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Fri, 30 Mar 2012 08:02:13 +0200 Subject: [PATCH 20/25] Fix rst syntax. --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 9ecdab59..0db00e67 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -29,7 +29,7 @@ Changelog * Fix W602, accept ``raise`` with 3 arguments. (Issue #34) -* Correctly select all tests if DEFAULT_IGNORE == ''. +* Correctly select all tests if ``DEFAULT_IGNORE == ''``. 0.6.1 (2010-10-03) From 2f4197641d994486784912a9cad66ecf174fdc65 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Fri, 30 Mar 2012 08:03:11 +0200 Subject: [PATCH 21/25] Obsolete todo items. --- TODO.txt | 4 ---- setup.py | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index d2aaf86c..2200e7c6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,8 +1,4 @@ TODO ==== -- Should command line option --repeat be enabled by default? - -- Does command line option --ignore properly prevent status code 1? - - Release version 1.0 after a brief stabilization period. diff --git a/setup.py b/setup.py index 882c9157..2f3eeeea 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ from setuptools import setup, find_packages -version = '0.7.0' +version = '0.7.1dev' long_description = '\n\n'.join([open('README.rst').read(), open('CHANGES.txt').read(), - open('TODO.txt').read()]) +# open('TODO.txt').read(), + ]) setup( name='pep8', From 7e66881ccc78ffc02f3bce0b96f594233ecf9d80 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Fri, 30 Mar 2012 08:04:49 +0200 Subject: [PATCH 22/25] Minor regression in the order the directories are walked. --- pep8.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pep8.py b/pep8.py index d3372480..2131d9e9 100755 --- a/pep8.py +++ b/pep8.py @@ -1036,7 +1036,8 @@ def input_dir(dirname, runner=None): if options.verbose: print('directory ' + root) options.counters['directories'] += 1 - for subdir in sorted(dirs): + dirs.sort() + for subdir in dirs[:]: if excluded(subdir): dirs.remove(subdir) files.sort() From 4dc6840eacbd7aa37f4a32cb96f24b40e774a8ff Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Fri, 30 Mar 2012 08:10:15 +0200 Subject: [PATCH 23/25] Adjust alignment. --- pep8.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pep8.py b/pep8.py index 2131d9e9..8445869a 100755 --- a/pep8.py +++ b/pep8.py @@ -1004,8 +1004,8 @@ def report_error(self, line_number, offset, text, check): self.file_errors += 1 if options.counters[code] == 1 or options.repeat: print("%s:%s:%d: %s" % - (self.filename, self.line_offset + line_number, - offset + 1, text)) + (self.filename, self.line_offset + line_number, + offset + 1, text)) if options.show_source: line = self.lines[line_number - 1] print(line.rstrip()) @@ -1142,8 +1142,8 @@ def print_benchmark(elapsed): print('%-7.2f %s' % (elapsed, 'seconds elapsed')) for key in BENCHMARK_KEYS: print('%-7d %s per second (%d total)' % ( - options.counters[key] / elapsed, key, - options.counters[key])) + options.counters[key] / elapsed, key, + options.counters[key])) def run_tests(filename): From 738715dd58d9566c44724b5d7353a7cf5a56f2f8 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 4 Apr 2012 00:05:25 +0200 Subject: [PATCH 24/25] Release 1.0. --- CHANGES.txt | 2 +- Makefile | 3 +++ TODO.txt | 4 ---- setup.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0db00e67..7e8f6ba1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,7 +2,7 @@ Changelog ========= -0.7.1 UNRELEASED +1.0 (2012-04-04) ---------------- * Fix W602 ``raise`` to handle multi-char names. (Issue #53) diff --git a/Makefile b/Makefile index e096cc3b..f2355b42 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ multitest : python2.7 pep8.py --testsuite testsuite python3.0 pep8.py --testsuite testsuite python3.1 pep8.py --testsuite testsuite + python3.2 pep8.py --testsuite testsuite python2.3 pep8.py --doctest python2.4 pep8.py --doctest python2.5 pep8.py --doctest @@ -24,6 +25,7 @@ multitest : python2.7 pep8.py --doctest python3.0 pep8.py --doctest python3.1 pep8.py --doctest + python3.2 pep8.py --doctest python2.3 pep8.py --repeat --statistics pep8.py python2.4 pep8.py --repeat --statistics pep8.py python2.5 pep8.py --repeat --statistics pep8.py @@ -31,3 +33,4 @@ multitest : python2.7 pep8.py --repeat --statistics pep8.py python3.0 pep8.py --repeat --statistics pep8.py python3.1 pep8.py --repeat --statistics pep8.py + python3.2 pep8.py --repeat --statistics pep8.py diff --git a/TODO.txt b/TODO.txt index 2200e7c6..e69de29b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +0,0 @@ -TODO -==== - -- Release version 1.0 after a brief stabilization period. diff --git a/setup.py b/setup.py index 2f3eeeea..881ce0b8 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.7.1dev' +version = '1.0' long_description = '\n\n'.join([open('README.rst').read(), open('CHANGES.txt').read(), # open('TODO.txt').read(), From 3df8635fedb722cad1d0587d7b87d79969030a62 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Fri, 6 Apr 2012 17:39:14 +0200 Subject: [PATCH 25/25] Release version 1.0.1 --- CHANGES.txt | 6 ++++++ pep8.py | 2 +- setup.py | 30 +++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7e8f6ba1..d91bd0da 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,12 @@ Changelog ========= +1.0.1 (2012-04-06) +------------------ + +* Fix inconsistent version numbers. + + 1.0 (2012-04-04) ---------------- diff --git a/pep8.py b/pep8.py index 8445869a..00687736 100755 --- a/pep8.py +++ b/pep8.py @@ -92,7 +92,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) """ -__version__ = '0.7.1dev' +__version__ = '1.0.1' import os import sys diff --git a/setup.py b/setup.py index 881ce0b8..cdf137c0 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,32 @@ from setuptools import setup, find_packages -version = '1.0' -long_description = '\n\n'.join([open('README.rst').read(), - open('CHANGES.txt').read(), -# open('TODO.txt').read(), - ]) + +def get_version(): + f = open('pep8.py') + try: + for line in f: + if line.startswith('__version__'): + return eval(line.split('=')[-1]) + finally: + f.close() + + +def get_long_description(): + descr = [] + for fname in 'README.rst', 'CHANGES.txt': # , 'TODO.txt' + f = open(fname) + try: + descr.append(f.read()) + finally: + f.close() + return '\n\n'.join(descr) + setup( name='pep8', - version=version, + version=get_version(), description="Python style guide checker", - long_description=long_description, + long_description=get_long_description(), keywords='pep8', author='Johann C. Rocholl', author_email='johann@rocholl.net',