Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ This is the current list of error and warning codes:
+------------+----------------------------------------------------------------------+
| E274 | tab before keyword |
+------------+----------------------------------------------------------------------+
| E275 | missing whitespace after keyword |
+------------+----------------------------------------------------------------------+
+------------+----------------------------------------------------------------------+
| **E3** | *Blank line* |
+------------+----------------------------------------------------------------------+
Expand Down
17 changes: 17 additions & 0 deletions pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,23 @@ def whitespace_around_keywords(logical_line):
yield match.start(2), "E271 multiple spaces after keyword"


def missing_whitespace_after_import_keyword(logical_line):
r"""Multiple imports in form from x import (a, b, c) should have space
between import statement and parenthesised name list.

Okay: from foo import (bar, baz)
E275: from foo import(bar, baz)
E275: from importable.module import(bar, baz)
"""
line = logical_line
indicator = ' import('
if line.startswith('from '):
found = line.find(indicator)
if -1 < found:
pos = found + len(indicator) - 1
yield pos, "E275 missing whitespace after keyword"


def missing_whitespace(logical_line):
r"""Each comma, semicolon or colon should be followed by whitespace.

Expand Down
14 changes: 14 additions & 0 deletions testsuite/E27.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,17 @@
a and b
#: E273 E274
this and False
#: Okay
from u import (a, b)
from v import c, d
#: E271
from w import (e, f)
#: E275
from w import(e, f)
#: E275
from importable.module import(e, f)
#: E275
try:
from importable.module import(e, f)
except ImportError:
pass