From 571d3ecdc0811f6eb1385d94e0a3de53da65097c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 30 Jul 2022 14:48:12 -0400 Subject: allow `is` and `is not` for type compares --- pycodestyle.py | 6 +++--- testsuite/E72.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pycodestyle.py b/pycodestyle.py index 4227e62..038727a 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -129,8 +129,8 @@ COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)' COMPARE_NEGATIVE_REGEX = re.compile(r'\b(?%&^]+|:=)(\s*)') @@ -1441,7 +1441,7 @@ def comparison_type(logical_line, noqa): Do not compare types directly. Okay: if isinstance(obj, int): - E721: if type(obj) is type(1): + E721: if type(obj) == type(1): """ match = COMPARE_TYPE_REGEX.search(logical_line) if match and not noqa: diff --git a/testsuite/E72.py b/testsuite/E72.py index 61e17eb..ac55a95 100644 --- a/testsuite/E72.py +++ b/testsuite/E72.py @@ -9,7 +9,7 @@ import types if res == types.IntType: pass -#: E721 +#: Okay import types if type(res) is not types.ListType: @@ -26,9 +26,9 @@ assert type(res) == type((0,)) assert type(res) == type((0)) #: E721 assert type(res) != type((1, )) -#: E721 +#: Okay assert type(res) is type((1, )) -#: E721 +#: Okay assert type(res) is not type((1, )) #: E211 E721 assert type(res) == type ([2, ]) -- cgit v1.2.1