Skip to content

Commit 0308f2f

Browse files
committed
A false positive E126 with embedded colon; fixes #144
1 parent f531c26 commit 0308f2f

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

CHANGES.txt

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

1818
* Fix a false positive E124 for hanging indent. (Issue #254)
1919

20+
* Fix a false positive E126 with embedded colon. (Issue #144)
21+
2022
* Fix behaviour when ``exclude`` is in the configuration file and
2123
the current directory is not the project directory. (Issue #247)
2224

pep8.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
516516
# special case for the "if" statement because len("if (") == 4
517517
elif not indent_chances and not row and not depth and text == 'if':
518518
indent_chances[end[1] + 1] = True
519+
elif text == ':' and line[end[1]:].isspace():
520+
open_rows[depth].append(row)
519521

520522
# keep track of bracket depth
521523
if token_type == tokenize.OP:

testsuite/E12.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,6 @@ def qualify_by_address(
248248
"long": "the quick brown fox jumps over the lazy dog before doing a "
249249
"somersault",
250250
}
251-
#: E126
252-
# probably not easily fixed, without using 'ast'
253-
troublesome_hash_ii = {
254-
"long key that tends to happen more when you're indented":
255-
"stringwithalongtoken you don't want to break",
256-
}
257251
#:
258252

259253

testsuite/E12not.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,4 +619,16 @@ def other_example():
619619
foo([
620620
'bug'
621621
])
622+
623+
# issue 144, finally!
624+
some_hash = {
625+
"long key that tends to happen more when you're indented":
626+
"stringwithalongtoken you don't want to break",
627+
}
628+
629+
{
630+
1:
631+
999999 if True
632+
else 0,
633+
}
622634
#

testsuite/E90.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pass
99
except:
1010
print 'Whoops'
11-
#: E122 E122 E225 E251 E251 E701
11+
#: E122 E225 E251 E251 E701
1212

1313
# Do not crash if code is invalid
1414
if msg:

0 commit comments

Comments
 (0)