diff options
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-x | pycodestyle.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index f5e05cf..4227e62 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -128,8 +128,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'|\btype(?:\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') @@ -1440,13 +1442,6 @@ def comparison_type(logical_line, noqa): Okay: if isinstance(obj, int): E721: if type(obj) is type(1): - - When checking if an object is a string, keep in mind that it might - be a unicode string too! In Python 2.3, str and unicode have a - 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: |