summaryrefslogtreecommitdiff
path: root/pep8.py
diff options
context:
space:
mode:
authorŁukasz Rogalski <rogalski.91@gmail.com>2016-03-23 23:24:51 +0100
committerŁukasz Rogalski <rogalski.91@gmail.com>2016-03-29 18:42:30 +0200
commitb7bf8c80608baa9ebbc6ab5c7692a58243c6f775 (patch)
treee4b985a471511fb1b78f7337bd3d7392e03a45e2 /pep8.py
parent2e151c544a4312ec9721c6abedd0f1e4067f9231 (diff)
downloadpep8-b7bf8c80608baa9ebbc6ab5c7692a58243c6f775.tar.gz
complain about missing space before opening parentheses of import statement
Solves issue #489
Diffstat (limited to 'pep8.py')
-rwxr-xr-xpep8.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/pep8.py b/pep8.py
index 39eb426..ec19dc5 100755
--- a/pep8.py
+++ b/pep8.py
@@ -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.