Skip to content

Commit 09ab13f

Browse files
authored
Merge pull request #1049 from asottile/type_compare_regex_bug
fix regex bug for E721
2 parents 0a58d33 + e4be8e7 commit 09ab13f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pycodestyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
r'(in|is)\s')
137137
COMPARE_TYPE_REGEX = re.compile(
138138
r'(?:[=!]=|is(?:\s+not)?)\s+type(?:\s*\(\s*([^)]*[^ )])\s*\))' +
139-
r'|type(?:\s*\(\s*([^)]*[^ )])\s*\))\s+(?:[=!]=|is(?:\s+not)?)'
139+
r'|\btype(?:\s*\(\s*([^)]*[^ )])\s*\))\s+(?:[=!]=|is(?:\s+not)?)'
140140
)
141141
KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS))
142142
OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)')

testsuite/E72.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,8 @@ def func_histype(a, b, c):
8383

8484
red = types.ColorTypeRED
8585
red is types.ColorType.RED
86+
#: Okay
87+
from . import compute_type
88+
89+
if compute_type(foo) == 5:
90+
pass

0 commit comments

Comments
 (0)