summaryrefslogtreecommitdiff
path: root/pycodestyle.py
diff options
context:
space:
mode:
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-xpycodestyle.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index ad17382..f70a1a6 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -1184,16 +1184,15 @@ def break_before_binary_operator(logical_line, tokens):
W503: (width == 0\n + height == 0)
W503: (width == 0\n and height == 0)
+ W503: var = (1\n & ~2)
+ W503: var = (1\n / -2)
+ W503: var = (1\n + -1\n + -2)
- Okay: (width == 0 +\n height == 0)
Okay: foo(\n -x)
Okay: foo(x\n [])
Okay: x = '''\n''' + ''
Okay: foo(x,\n -y)
Okay: foo(x, # comment\n -y)
- Okay: var = (1 &\n ~2)
- Okay: var = (1 /\n -2)
- Okay: var = (1 +\n -1 +\n -2)
"""
for context in _break_around_binary_operators(tokens):
(token_type, text, previous_token_type, previous_text,
@@ -1215,25 +1214,26 @@ def break_after_binary_operator(logical_line, tokens):
W504: (width == 0 +\n height == 0)
W504: (width == 0 and\n height == 0)
+ W504: var = (1 &\n ~2)
- Okay: (width == 0\n + height == 0)
Okay: foo(\n -x)
Okay: foo(x\n [])
Okay: x = '''\n''' + ''
Okay: x = '' + '''\n'''
Okay: foo(x,\n -y)
Okay: foo(x, # comment\n -y)
- Okay: var = (1\n & ~2)
- Okay: var = (1\n / -2)
- Okay: var = (1\n + -1\n + -2)
+
+ The following should be W504 but unary_context is tricky with these
+ Okay: var = (1 /\n -2)
+ Okay: var = (1 +\n -1 +\n -2)
"""
for context in _break_around_binary_operators(tokens):
(token_type, text, previous_token_type, previous_text,
line_break, unary_context, start) = context
- if (_is_binary_operator(previous_token_type, previous_text)
- and line_break
- and not unary_context
- and not _is_binary_operator(token_type, text)):
+ if (_is_binary_operator(previous_token_type, previous_text) and
+ line_break and
+ not unary_context and
+ not _is_binary_operator(token_type, text)):
error_pos = (start[0] - 1, start[1])
yield error_pos, "W504 line break after binary operator"