Skip to content

Commit c812090

Browse files
committed
Fix E70x not detected sometimes; issue #196
1 parent 00aff36 commit c812090

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Changelog
2222

2323
* Fix false positive E261/E262 when the file contains a BOM. (Issue #193)
2424

25+
* Fix E701, E702 and E703 not detected sometimes. (Issue #196)
26+
2527

2628
1.4.5 (2013-03-06)
2729
------------------

pep8.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,19 +842,21 @@ def compound_statements(logical_line):
842842
line = logical_line
843843
last_char = len(line) - 1
844844
found = line.find(':')
845-
if -1 < found < last_char:
845+
while -1 < found < last_char:
846846
before = line[:found]
847847
if (before.count('{') <= before.count('}') and # {'a': 1} (dict)
848848
before.count('[') <= before.count(']') and # [1:2] (slice)
849849
before.count('(') <= before.count(')') and # (Python 3 annotation)
850850
not LAMBDA_REGEX.search(before)): # lambda x: x
851851
yield found, "E701 multiple statements on one line (colon)"
852+
found = line.find(':', found + 1)
852853
found = line.find(';')
853-
if -1 < found:
854+
while -1 < found:
854855
if found < last_char:
855856
yield found, "E702 multiple statements on one line (semicolon)"
856857
else:
857858
yield found, "E703 statement ends with a semicolon"
859+
found = line.find(';', found + 1)
858860

859861

860862
def explicit_line_join(logical_line, tokens):

testsuite/E70.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#: E701
22
if a: a = False
3+
#: E701
4+
if not header or header[:6] != 'bytes=': return
35
#: E702
46
a = False; b = True
57
#: E702
68
import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe)
79
#: E703
810
import shlex;
11+
#: E702 E703
12+
del a[:]; a.append(42);
913
#:

0 commit comments

Comments
 (0)