diff --git a/pycodestyle.py b/pycodestyle.py index 868e79d5..e53e8b0d 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -121,8 +121,8 @@ COMPARE_NEGATIVE_REGEX = re.compile(r'\b(?%&^]+|:=)(\s*)') @@ -1498,12 +1498,11 @@ def comparison_type(logical_line, noqa): Okay: if isinstance(obj, int): Okay: if type(obj) is int: E721: if type(obj) == type(1): + E721: if type(obj) == int: + E721: if int == type(obj): """ match = COMPARE_TYPE_REGEX.search(logical_line) if match and not noqa: - inst = match.group(1) - if inst and inst.isidentifier() and inst not in SINGLETONS: - return # Allow comparison for types which are not obvious yield ( match.start(), "E721 do not compare types, for exact checks use `is` / `is not`, " diff --git a/testing/data/E72.py b/testing/data/E72.py index 5d1046cb..d74350e8 100644 --- a/testing/data/E72.py +++ b/testing/data/E72.py @@ -4,6 +4,12 @@ #: E721 if type(res) != type(""): pass +#: E721 +if int == type(res): + pass +#: E721 +if str != type(res): + pass #: Okay res.type("") == "" #: Okay