Skip to content

Commit f82bf22

Browse files
committed
Merge pull request #171 from ymattw/e251-spaces
Fix misleading error message for E251
2 parents 5bba042 + 5657753 commit f82bf22

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

docs/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ This is the current list of error and warning codes:
245245
| E242 (*) | tab after ',' |
246246
+----------+----------------------------------------------------------------------+
247247
+----------+----------------------------------------------------------------------+
248-
| E251 | no spaces around keyword / parameter equals |
248+
| E251 | unexpected spaces around keyword / parameter equals |
249249
+----------+----------------------------------------------------------------------+
250250
+----------+----------------------------------------------------------------------+
251251
| E261 | at least two spaces before inline comment |

pep8.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,12 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
751751
parens = 0
752752
no_space = False
753753
prev_end = None
754+
message = "E251 unexpected spaces around keyword / parameter equals"
754755
for token_type, text, start, end, line in tokens:
755756
if no_space:
756757
no_space = False
757758
if start != prev_end:
758-
yield (prev_end,
759-
"E251 no spaces around keyword / parameter equals")
759+
yield (prev_end, message)
760760
elif token_type == tokenize.OP:
761761
if text == '(':
762762
parens += 1
@@ -765,8 +765,7 @@ def whitespace_around_named_parameter_equals(logical_line, tokens):
765765
elif parens and text == '=':
766766
no_space = True
767767
if start != prev_end:
768-
yield (prev_end,
769-
"E251 no spaces around keyword / parameter equals")
768+
yield (prev_end, message)
770769
prev_end = end
771770

772771

0 commit comments

Comments
 (0)