[Python-modules-commits] [pycodestyle] 01/04: Import pycodestyle_2.3.1.orig.tar.gz
Ondřej Nový
onovy at moszumanska.debian.org
Tue Feb 21 08:45:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
onovy pushed a commit to branch experimental
in repository pycodestyle.
commit 9d249cc076c3180b65de9b90d173fcb1b15dc665
Author: Ondřej Nový <onovy at debian.org>
Date: Tue Feb 21 09:37:28 2017 +0100
Import pycodestyle_2.3.1.orig.tar.gz
---
CHANGES.txt | 24 +++++++++++++++++++
PKG-INFO | 26 ++++++++++++++++++++-
docs/intro.rst | 2 ++
pycodestyle.egg-info/PKG-INFO | 26 ++++++++++++++++++++-
pycodestyle.egg-info/SOURCES.txt | 1 +
pycodestyle.py | 49 +++++++++++++++++++++++++++++++++------
testsuite/.E30not.py.swp | Bin 0 -> 12288 bytes
testsuite/E25.py | 4 ++++
testsuite/E30.py | 9 ++++++-
testsuite/E30not.py | 11 +++++++++
testsuite/E40.py | 12 ++++++++--
testsuite/E70.py | 4 ++++
testsuite/E72.py | 28 ++++++++++++++++++++++
testsuite/E90.py | 2 +-
testsuite/python3.py | 12 ++++++++++
15 files changed, 197 insertions(+), 13 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index aeb5d63..230e2d8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,29 @@
Changelog
=========
+2.3.1 (2017-01-31)
+------------------
+
+Bugs:
+
+* Fix regression in detection of E302 and E306; #618, #620
+
+2.3.0 (2017-01-30)
+------------------
+
+New Checks:
+
+* Add E722 warning for bare ``except`` clauses
+* Report E704 for async function definitions (``async def``)
+
+Bugs:
+
+* Fix another E305 false positive for variables beginning with "class" or
+ "def"
+* Fix detection of multiple spaces betwen ``async`` and ``def``
+* Fix handling of variable annotations. Stop reporting E701 on Python 3.6 for
+ variable annotations.
+
2.2.0 (2016-11-14)
------------------
@@ -28,6 +51,7 @@ Changes:
* Report E741 on 'global' and 'nonlocal' statements, as well as prohibited
single-letter variables.
* Deprecated use of `[pep8]` section name in favor of `[pycodestyle]`; #591
+* Report E722 when bare except clause is used; #579
Bugs:
diff --git a/PKG-INFO b/PKG-INFO
index baeeeac..3f0e6dd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pycodestyle
-Version: 2.2.0
+Version: 2.3.1
Summary: Python style guide checker
Home-page: https://pycodestyle.readthedocs.io/
Author: Ian Lee
@@ -119,6 +119,29 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
Changelog
=========
+ 2.3.1 (2017-01-31)
+ ------------------
+
+ Bugs:
+
+ * Fix regression in detection of E302 and E306; #618, #620
+
+ 2.3.0 (2017-01-30)
+ ------------------
+
+ New Checks:
+
+ * Add E722 warning for bare ``except`` clauses
+ * Report E704 for async function definitions (``async def``)
+
+ Bugs:
+
+ * Fix another E305 false positive for variables beginning with "class" or
+ "def"
+ * Fix detection of multiple spaces betwen ``async`` and ``def``
+ * Fix handling of variable annotations. Stop reporting E701 on Python 3.6 for
+ variable annotations.
+
2.2.0 (2016-11-14)
------------------
@@ -146,6 +169,7 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
* Report E741 on 'global' and 'nonlocal' statements, as well as prohibited
single-letter variables.
* Deprecated use of `[pep8]` section name in favor of `[pycodestyle]`; #591
+ * Report E722 when bare except clause is used; #579
Bugs:
diff --git a/docs/intro.rst b/docs/intro.rst
index b1dc689..fcdcf72 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -361,6 +361,8 @@ This is the current list of error and warning codes:
+------------+----------------------------------------------------------------------+
| E721 (^) | do not compare types, use 'isinstance()' |
+------------+----------------------------------------------------------------------+
+| E722 | do not use bare except, specify exception instead |
++------------+----------------------------------------------------------------------+
| E731 | do not assign a lambda expression, use a def |
+------------+----------------------------------------------------------------------+
| E741 | do not use variables named 'l', 'O', or 'I' |
diff --git a/pycodestyle.egg-info/PKG-INFO b/pycodestyle.egg-info/PKG-INFO
index baeeeac..3f0e6dd 100644
--- a/pycodestyle.egg-info/PKG-INFO
+++ b/pycodestyle.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pycodestyle
-Version: 2.2.0
+Version: 2.3.1
Summary: Python style guide checker
Home-page: https://pycodestyle.readthedocs.io/
Author: Ian Lee
@@ -119,6 +119,29 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
Changelog
=========
+ 2.3.1 (2017-01-31)
+ ------------------
+
+ Bugs:
+
+ * Fix regression in detection of E302 and E306; #618, #620
+
+ 2.3.0 (2017-01-30)
+ ------------------
+
+ New Checks:
+
+ * Add E722 warning for bare ``except`` clauses
+ * Report E704 for async function definitions (``async def``)
+
+ Bugs:
+
+ * Fix another E305 false positive for variables beginning with "class" or
+ "def"
+ * Fix detection of multiple spaces betwen ``async`` and ``def``
+ * Fix handling of variable annotations. Stop reporting E701 on Python 3.6 for
+ variable annotations.
+
2.2.0 (2016-11-14)
------------------
@@ -146,6 +169,7 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
* Report E741 on 'global' and 'nonlocal' statements, as well as prohibited
single-letter variables.
* Deprecated use of `[pep8]` section name in favor of `[pycodestyle]`; #591
+ * Report E722 when bare except clause is used; #579
Bugs:
diff --git a/pycodestyle.egg-info/SOURCES.txt b/pycodestyle.egg-info/SOURCES.txt
index 7e4b2fe..a68ad7f 100644
--- a/pycodestyle.egg-info/SOURCES.txt
+++ b/pycodestyle.egg-info/SOURCES.txt
@@ -21,6 +21,7 @@ pycodestyle.egg-info/entry_points.txt
pycodestyle.egg-info/namespace_packages.txt
pycodestyle.egg-info/not-zip-safe
pycodestyle.egg-info/top_level.txt
+testsuite/.E30not.py.swp
testsuite/E10.py
testsuite/E11.py
testsuite/E12.py
diff --git a/pycodestyle.py b/pycodestyle.py
index e308177..5d8c2ac 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -66,7 +66,7 @@ try:
except ImportError:
from ConfigParser import RawConfigParser
-__version__ = '2.2.0'
+__version__ = '2.3.1'
DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'
DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503'
@@ -121,6 +121,20 @@ KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS))
OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)')
LAMBDA_REGEX = re.compile(r'\blambda\b')
HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
+STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)')
+STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def\s+|def\s+|class\s+|@)')
+STARTSWITH_INDENT_STATEMENT_REGEX = re.compile(
+ r'^\s*({0})'.format('|'.join(s.replace(' ', '\s+') for s in (
+ 'def', 'async def',
+ 'for', 'async for',
+ 'if', 'elif', 'else',
+ 'try', 'except', 'finally',
+ 'with', 'async with',
+ 'class',
+ 'while',
+ )))
+)
+DUNDER_REGEX = re.compile(r'^__([^\s]+)__ = ')
# Work around Python < 2.6 behaviour, which does not generate NL after
# a comment which is on a line by itself.
@@ -264,6 +278,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
E303: def a():\n\n\n\n pass
E304: @decorator\n\ndef a():\n pass
E305: def a():\n pass\na()
+ E306: def a():\n def b():\n pass\n def c():\n pass
"""
if line_number < 3 and not previous_logical:
return # Don't expect blank lines before the first line
@@ -272,7 +287,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
yield 0, "E304 blank lines found after function decorator"
elif blank_lines > 2 or (indent_level and blank_lines == 2):
yield 0, "E303 too many blank lines (%d)" % blank_lines
- elif logical_line.startswith(('def ', 'async def', 'class ', '@')):
+ elif STARTSWITH_TOP_LEVEL_REGEX.match(logical_line):
if indent_level:
if not (blank_before or previous_indent_level < indent_level or
DOCSTRING_REGEX.match(previous_logical)):
@@ -813,7 +828,7 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
no_space = False
prev_end = None
annotated_func_arg = False
- in_def = logical_line.startswith(('def', 'async def'))
+ in_def = bool(STARTSWITH_DEF_REGEX.match(logical_line))
message = "E251 unexpected spaces around keyword / parameter equals"
for token_type, text, start, end, line in tokens:
if token_type == tokenize.NL:
@@ -912,8 +927,10 @@ def module_imports_on_top_of_file(
Okay: # this is a comment\nimport os
Okay: '''this is a module docstring'''\nimport os
Okay: r'''this is a module docstring'''\nimport os
- Okay: try:\n import x\nexcept:\n pass\nelse:\n pass\nimport y
- Okay: try:\n import x\nexcept:\n pass\nfinally:\n pass\nimport y
+ Okay:
+ try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
+ Okay:
+ try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
E402: a=1\nimport os
E402: 'One string'\n"Two string"\nimport os
E402: a=1\nfrom sys import x
@@ -939,6 +956,8 @@ def module_imports_on_top_of_file(
if line.startswith('import ') or line.startswith('from '):
if checker_state.get('seen_non_imports', False):
yield 0, "E402 module level import not at top of file"
+ elif re.match(DUNDER_REGEX, line):
+ return
elif any(line.startswith(kw) for kw in allowed_try_keywords):
# Allow try, except, else, finally keywords intermixed with imports in
# order to support conditional importing
@@ -998,9 +1017,9 @@ def compound_statements(logical_line):
yield 0, ("E731 do not assign a lambda expression, use a "
"def")
break
- if line.startswith('def '):
+ if STARTSWITH_DEF_REGEX.match(line):
yield 0, "E704 multiple statements on one line (def)"
- else:
+ elif STARTSWITH_INDENT_STATEMENT_REGEX.match(line):
yield found, "E701 multiple statements on one line (colon)"
prev_found = found
found = line.find(':', found + 1)
@@ -1179,6 +1198,22 @@ def comparison_type(logical_line, noqa):
yield match.start(), "E721 do not compare types, use 'isinstance()'"
+def bare_except(logical_line, noqa):
+ r"""When catching exceptions, mention specific exceptions whenever possible.
+
+ Okay: except Exception:
+ Okay: except BaseException:
+ E722: except:
+ """
+ if noqa:
+ return
+
+ regex = re.compile(r"except\s*:")
+ match = regex.match(logical_line)
+ if match:
+ yield match.start(), "E722 do not use bare except'"
+
+
def ambiguous_identifier(logical_line, tokens):
r"""Never use the characters 'l', 'O', or 'I' as variable names.
diff --git a/testsuite/.E30not.py.swp b/testsuite/.E30not.py.swp
new file mode 100644
index 0000000..2e09201
Binary files /dev/null and b/testsuite/.E30not.py.swp differ
diff --git a/testsuite/E25.py b/testsuite/E25.py
index 7a536b5..dde95b8 100644
--- a/testsuite/E25.py
+++ b/testsuite/E25.py
@@ -38,3 +38,7 @@ def munge(input: AnyStr, sep: AnyStr = None, limit=1000,
#: Okay
async def add(a: int = 0, b: int = 0) -> int:
return a + b
+# Previously E251 four times
+#: E272:1:6
+async def add(a: int = 0, b: int = 0) -> int:
+ return a + b
diff --git a/testsuite/E30.py b/testsuite/E30.py
index 105d368..bd74b80 100644
--- a/testsuite/E30.py
+++ b/testsuite/E30.py
@@ -113,7 +113,7 @@ def a():
try:
a()
-except:
+except Exception:
pass
#: E305:5:1
def a():
@@ -156,3 +156,10 @@ def main():
if __name__ == '__main__':
main()
+# Previously just E272:1:6 E272:4:6
+#: E302:4:1 E272:1:6 E272:4:6
+async def x():
+ pass
+
+async def x(y: int = 1):
+ pass
diff --git a/testsuite/E30not.py b/testsuite/E30not.py
index ea75057..6303b3b 100644
--- a/testsuite/E30not.py
+++ b/testsuite/E30not.py
@@ -151,3 +151,14 @@ class Bar(object):
if __name__ == '__main__':
foo()
+#: Okay
+classification_errors = None
+#: Okay
+defined_properly = True
+#: Okay
+defaults = {}
+defaults.update({})
+#: Okay
+def foo(x):
+ classification = x
+ definitely = not classification
diff --git a/testsuite/E40.py b/testsuite/E40.py
index 1051e32..f9a18fc 100644
--- a/testsuite/E40.py
+++ b/testsuite/E40.py
@@ -11,14 +11,22 @@ from foo.bar.yourclass import YourClass
import myclass
import foo.bar.yourclass
-#: E402
+#: Okay
__all__ = ['abc']
import foo
#: Okay
+__version__ = "42"
+
+import foo
+#: Okay
+__author__ = "Simon Gomizelj"
+
+import foo
+#: Okay
try:
import foo
-except:
+except ImportError:
pass
else:
print('imported foo')
diff --git a/testsuite/E70.py b/testsuite/E70.py
index 85ca666..caafe45 100644
--- a/testsuite/E70.py
+++ b/testsuite/E70.py
@@ -12,6 +12,10 @@ import shlex;
del a[:]; a.append(42);
#: E704:1:1
def f(x): return 2
+#: E704:1:1
+async def f(x): return 2
+#: E704:1:1 E272:1:6
+async def f(x): return 2
#: E704:1:1 E226:1:19
def f(x): return 2*x
#: E704:2:5 E226:2:23
diff --git a/testsuite/E72.py b/testsuite/E72.py
index 8eb34cb..c18527f 100644
--- a/testsuite/E72.py
+++ b/testsuite/E72.py
@@ -49,3 +49,31 @@ if isinstance(res, types.MethodType):
pass
if type(a) != type(b) or type(a) == type(ccc):
pass
+#: E722
+try:
+ pass
+except:
+ pass
+#: E722
+try:
+ pass
+except Exception:
+ pass
+except:
+ pass
+#: E722 E203 E271
+try:
+ pass
+except :
+ pass
+#: Okay
+fake_code = """"
+try:
+ do_something()
+except:
+ pass
+"""
+try:
+ pass
+except Exception:
+ pass
diff --git a/testsuite/E90.py b/testsuite/E90.py
index 1db3d0e..2c18e9a 100644
--- a/testsuite/E90.py
+++ b/testsuite/E90.py
@@ -8,7 +8,7 @@ while True:
pass
except:
print 'Whoops'
-#: E122 E225 E251 E251 E701
+#: E122 E225 E251 E251
# Do not crash if code is invalid
if msg:
diff --git a/testsuite/python3.py b/testsuite/python3.py
index 8881880..fde4281 100644
--- a/testsuite/python3.py
+++ b/testsuite/python3.py
@@ -1,6 +1,18 @@
#!/usr/bin/env python3
+from typing import ClassVar, List
# Annotated function (Issue #29)
def foo(x: int) -> int:
return x + 1
+
+
+# Annotated variables #575
+CONST: int = 42
+
+
+class Class:
+ cls_var: ClassVar[str]
+
+ def m(self):
+ xs: List[int] = []
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pycodestyle.git
More information about the Python-modules-commits
mailing list