Skip to content

Commit

Permalink
Add tests, and changelog entry about W293.
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed Aug 29, 2010
1 parent 420e3b2 commit 5ff4427
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Changelog
0.5.1 (unreleased)
------------------

* Blank lines with spaces yield W293 instead of W291: some developers
want to ignore this warning and indent the blank lines to paste their
code easily in the Python interpreter.

* Fix E301: do not require a blank line before an indented block. (Issue #14)

* Fix E203 to accept NumPy slice notation ``a[0, :]``. (Issue #13)
Expand Down
6 changes: 4 additions & 2 deletions pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ def trailing_whitespace(physical_line):
physical_line = physical_line.rstrip('\x0c') # chr(12), form feed, ^L
stripped = physical_line.rstrip()
if physical_line != stripped:
warning_code = "W291" if stripped != '' else "W293"
return len(stripped), "%s trailing whitespace" % warning_code
if stripped:
return len(stripped), "W291 trailing whitespace"
else:
return 0, "W293 blank line contains whitespace"


def trailing_blank_lines(physical_line, lines, line_number):
Expand Down
3 changes: 3 additions & 0 deletions testsuite/W291not.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Foo(object):

bang = 12
3 changes: 3 additions & 0 deletions testsuite/W293.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Foo(object):

bang = 12

0 comments on commit 5ff4427

Please sign in to comment.