Skip to content

Commit 9f6a181

Browse files
committed
Revert "Merge pull request #1085 from PyCQA/revert-1041"
This reverts commit ab806f3, reversing changes made to d356662.
1 parent 9a0da24 commit 9f6a181

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

pycodestyle.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@
128128
r'\s*(?(1)|(None|False|True))\b')
129129
COMPARE_NEGATIVE_REGEX = re.compile(r'\b(?<!is\s)(not)\s+[^][)(}{ ]+\s+'
130130
r'(in|is)\s')
131-
COMPARE_TYPE_REGEX = re.compile(r'(?:[=!]=|is(?:\s+not)?)\s+type(?:s.\w+Type'
132-
r'|\s*\(\s*([^)]*[^ )])\s*\))')
131+
COMPARE_TYPE_REGEX = re.compile(
132+
r'(?:[=!]=|is(?:\s+not)?)\s+type(?:\s*\(\s*([^)]*[^ )])\s*\))' +
133+
r'|\btype(?:\s*\(\s*([^)]*[^ )])\s*\))\s+(?:[=!]=|is(?:\s+not)?)'
134+
)
133135
KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS))
134136
OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)')
135137
LAMBDA_REGEX = re.compile(r'\blambda\b')
@@ -1458,13 +1460,6 @@ def comparison_type(logical_line, noqa):
14581460
14591461
Okay: if isinstance(obj, int):
14601462
E721: if type(obj) is type(1):
1461-
1462-
When checking if an object is a string, keep in mind that it might
1463-
be a unicode string too! In Python 2.3, str and unicode have a
1464-
common base class, basestring, so you can do:
1465-
1466-
Okay: if isinstance(obj, basestring):
1467-
Okay: if type(a1) is type(b1):
14681463
"""
14691464
match = COMPARE_TYPE_REGEX.search(logical_line)
14701465
if match and not noqa:

testsuite/E72.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#: E721
55
if type(res) != type(""):
66
pass
7-
#: E721
7+
#: Okay
88
import types
99

1010
if res == types.IntType:
@@ -47,8 +47,6 @@
4747
pass
4848
if isinstance(res, types.MethodType):
4949
pass
50-
if type(a) != type(b) or type(a) == type(ccc):
51-
pass
5250
#: Okay
5351
def func_histype(a, b, c):
5452
pass
@@ -81,6 +79,11 @@ def func_histype(a, b, c):
8179
except Exception:
8280
pass
8381
#: Okay
82+
from . import custom_types as types
83+
84+
red = types.ColorTypeRED
85+
red is types.ColorType.RED
86+
#: Okay
8487
from . import compute_type
8588

8689
if compute_type(foo) == 5:

0 commit comments

Comments
 (0)