Skip to content

Commit

Permalink
E225 allows lambda function arguments with keyword defaults and print…
Browse files Browse the repository at this point in the history
… statement extended form.
  • Loading branch information
florentx committed Oct 24, 2009
1 parent fc059fb commit 7d294a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
14 changes: 10 additions & 4 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ Changelog
0.5 (unreleased)
----------------

* Reserve "2 blank lines" for module-level logical blocks (E303)

* Performance improvement, due to rewriting of E225

* E225 should allow no white space after unary operator (Issue #9)
* E225 now accepts:

- no whitespace after unary operator or similar (Issue #9)

- lambda function with argument unpacking or keyword defaults

- print statement extended form: ``print >>sys.stderr, "Hello world!"``

* Reserve "2 blank lines" for module-level logical blocks (E303)

* Allow multi-line comments (E302, issue #10)

Expand All @@ -32,7 +38,7 @@ Changelog
* Further improvements to the handling of comments and blank lines.
(Issue #1 and others changes.)

* check all py files in directory when passed a directory (Issue
* Check all py files in directory when passed a directory (Issue
#2). This also prevents an exception when traversing directories
with non ``*.py`` files.

Expand Down
11 changes: 5 additions & 6 deletions pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number)

WHITESPACE = ' \t'

# Longer operators (containing others) must come first.
BINARY_OPERATORS = """
+= != **= //= /= %= ^= &= |= == >>= <<= <= >=
-= <> *= // / % ^ & | = >> << < >
+= != %= ^= &= |= == **= //= >>= <<= // <<
-= <> % ^ & | = *= /= >= <= / < >
""".split()
UNARY_OPERATORS = ['**', '*', '+', '-']
UNARY_OPERATORS = ['**', '*', '+', '-', '>>']
OPERATORS = BINARY_OPERATORS + UNARY_OPERATORS

options = None
Expand Down Expand Up @@ -446,9 +445,9 @@ def missing_whitespace_around_operator(logical_line, tokens):
for token_type, text, start, end, line in tokens:
if token_type in (tokenize.NL, tokenize.NEWLINE):
continue
if text == '(':
if text in ('(', 'lambda'):
parens += 1
elif text == ')':
elif text in (')', ':'):
parens -= 1
if need_space:
if start == prev_end:
Expand Down
3 changes: 2 additions & 1 deletion testsuite/E225not.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
negative = -1
spam(-1)
lambda *args, **kw: (args, kw)
lambda a, b='': (a, b)
if not -5 < x < +5:
pass
print >>sys.stderr, "x is out of range."

0 comments on commit 7d294a6

Please sign in to comment.