From 48b83c91e4372e17c8633c4082b2967a18d3415f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 30 Jul 2022 15:13:05 -0400 Subject: Revert "Merge pull request #1085 from PyCQA/revert-1041" This reverts commit ab806f3f9133ca24366b6254e499f0363f6bf5ec, reversing changes made to d3566623bb451f6c7f1b65cc4f8538d2540da9e6. --- pycodestyle.py | 13 ++++--------- 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(?%&^]+|:=)(\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: -- cgit v1.2.1