summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2013-05-03 23:23:49 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2013-05-03 23:23:49 +0200
commitc8120906884df69de75827c3351ef5eb12fd6c1a (patch)
treeab9b62cef29d12b661df2cded6955b9331326370
parent00aff369146b3955feaa83fe7a0136d4b24a6c08 (diff)
downloadpep8-c8120906884df69de75827c3351ef5eb12fd6c1a.tar.gz
Fix E70x not detected sometimes; issue #196
-rw-r--r--CHANGES.txt2
-rwxr-xr-xpep8.py6
-rw-r--r--testsuite/E70.py4
3 files changed, 10 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 17fad0d..9e346c5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -22,6 +22,8 @@ Changelog
* Fix false positive E261/E262 when the file contains a BOM. (Issue #193)
+* Fix E701, E702 and E703 not detected sometimes. (Issue #196)
+
1.4.5 (2013-03-06)
------------------
diff --git a/pep8.py b/pep8.py
index e586c1d..b50a30c 100755
--- a/pep8.py
+++ b/pep8.py
@@ -842,19 +842,21 @@ def compound_statements(logical_line):
line = logical_line
last_char = len(line) - 1
found = line.find(':')
- if -1 < found < last_char:
+ while -1 < found < last_char:
before = line[:found]
if (before.count('{') <= before.count('}') and # {'a': 1} (dict)
before.count('[') <= before.count(']') and # [1:2] (slice)
before.count('(') <= before.count(')') and # (Python 3 annotation)
not LAMBDA_REGEX.search(before)): # lambda x: x
yield found, "E701 multiple statements on one line (colon)"
+ found = line.find(':', found + 1)
found = line.find(';')
- if -1 < found:
+ while -1 < found:
if found < last_char:
yield found, "E702 multiple statements on one line (semicolon)"
else:
yield found, "E703 statement ends with a semicolon"
+ found = line.find(';', found + 1)
def explicit_line_join(logical_line, tokens):
diff --git a/testsuite/E70.py b/testsuite/E70.py
index 8941ab1..64feefd 100644
--- a/testsuite/E70.py
+++ b/testsuite/E70.py
@@ -1,9 +1,13 @@
#: E701
if a: a = False
+#: E701
+if not header or header[:6] != 'bytes=': return
#: E702
a = False; b = True
#: E702
import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe)
#: E703
import shlex;
+#: E702 E703
+del a[:]; a.append(42);
#: