Skip to content

Commit 1aa4c0a

Browse files
authored
Merge pull request #931 from suzil/fix/767/chained-is-not-E714
E714: fix chained `is not`
2 parents 90026af + 39895aa commit 1aa4c0a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pycodestyle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
140140
WHITESPACE_AFTER_COMMA_REGEX = re.compile(r'[,;:]\s*(?: |\t)')
141141
COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)'
142142
r'\s*(?(1)|(None|False|True))\b')
143-
COMPARE_NEGATIVE_REGEX = re.compile(r'\b(not)\s+[^][)(}{ ]+\s+(in|is)\s')
143+
COMPARE_NEGATIVE_REGEX = re.compile(r'\b(?<!is\s)(not)\s+[^][)(}{ ]+\s+'
144+
r'(in|is)\s')
144145
COMPARE_TYPE_REGEX = re.compile(r'(?:[=!]=|is(?:\s+not)?)\s+type(?:s.\w+Type'
145146
r'|\s*\(\s*([^)]*[^ )])\s*\))')
146147
KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS))

testsuite/E71.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
#: E714
6565
if not X.B is Y:
6666
pass
67+
#: E714
68+
if not X is Y is not Z:
69+
pass
70+
#: E714
71+
if not X is not Y:
72+
pass
6773

6874
#
6975
#: Okay
@@ -79,6 +85,9 @@
7985
if x is not y:
8086
pass
8187

88+
if X is not Y is not Z:
89+
pass
90+
8291
if TrueElement.get_element(True) == TrueElement.get_element(False):
8392
pass
8493

0 commit comments

Comments
 (0)