diff options
author | Anthony Sottile <asottile@umich.edu> | 2022-07-30 15:13:05 -0400 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2022-12-21 12:46:12 -0500 |
commit | 48b83c91e4372e17c8633c4082b2967a18d3415f (patch) | |
tree | 1e1dedbefc3c47a72723abb140ed3744965aa2ec | |
parent | b22b672a1a53f1ef35c4f4689c674d66a24138ed (diff) | |
download | pep8-48b83c91e4372e17c8633c4082b2967a18d3415f.tar.gz |
Revert "Merge pull request #1085 from PyCQA/revert-1041"
This reverts commit ab806f3f9133ca24366b6254e499f0363f6bf5ec, reversing
changes made to d3566623bb451f6c7f1b65cc4f8538d2540da9e6.
-rwxr-xr-x | pycodestyle.py | 13 | ||||
-rw-r--r-- | testsuite/E72.py | 9 |
2 files changed, 10 insertions, 12 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: diff --git a/testsuite/E72.py b/testsuite/E72.py index d127ff7..61e17eb 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 @@ -81,6 +79,11 @@ try: except Exception: pass #: Okay +from . import custom_types as types + +red = types.ColorTypeRED +red is types.ColorType.RED +#: Okay from . import compute_type if compute_type(foo) == 5: |