diff options
-rwxr-xr-x | pycodestyle.py | 7 | ||||
-rw-r--r-- | testsuite/E72.py | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index b839e35..c71071e 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -144,8 +144,10 @@ COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)' r'\s*(?(1)|(None|False|True))\b') COMPARE_NEGATIVE_REGEX = re.compile(r'\b(?<!is\s)(not)\s+[^][)(}{ ]+\s+' r'(in|is)\s') -COMPARE_TYPE_REGEX = re.compile(r'(?:[=!]=|is(?:\s+not)?)\s+type(?:s.\w+Type' - r'|\s*\(\s*([^)]*[^ )])\s*\))') +COMPARE_TYPE_REGEX = re.compile( + r'(?:[=!]=|is(?:\s+not)?)\s+type(?:\s*\(\s*([^)]*[^ )])\s*\))' + + r'|type(?:\s*\(\s*([^)]*[^ )])\s*\))\s+(?:[=!]=|is(?:\s+not)?)' +) KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS)) OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)') LAMBDA_REGEX = re.compile(r'\blambda\b') @@ -1463,7 +1465,6 @@ def comparison_type(logical_line, noqa): common base class, basestring, so you can do: Okay: if isinstance(obj, basestring): - Okay: if type(a1) is type(b1): """ match = COMPARE_TYPE_REGEX.search(logical_line) if match and not noqa: diff --git a/testsuite/E72.py b/testsuite/E72.py index a60d892..bba55f5 100644 --- a/testsuite/E72.py +++ b/testsuite/E72.py @@ -4,7 +4,7 @@ if type(res) == type(42): #: E721 if type(res) != type(""): pass -#: E721 +#: Okay import types if res == types.IntType: @@ -47,8 +47,6 @@ if isinstance(res, str): pass if isinstance(res, types.MethodType): pass -if type(a) != type(b) or type(a) == type(ccc): - pass #: Okay def func_histype(a, b, c): pass @@ -80,3 +78,8 @@ try: pass except Exception: pass +#: Okay +from . import custom_types as types + +red = types.ColorTypeRED +red is types.ColorType.RED |