diff options
author | Pavel Savchenko <asfaltboy@gmail.com> | 2021-12-12 09:24:39 +0000 |
---|---|---|
committer | Pavel Savchenko <asfaltboy@gmail.com> | 2021-12-12 09:24:39 +0000 |
commit | dcedb98f17514cc3174313fd0f009d460fa7babb (patch) | |
tree | 8a0c30a45cd5a43a422e42592ba4885ae55d5645 | |
parent | f3ee72b75a4df32221ab08d315e0614a59c17f26 (diff) | |
download | pep8-dcedb98f17514cc3174313fd0f009d460fa7babb.tar.gz |
Correct test assertions for E721
* `type(a) is type(b)` should still fail
* same for `type(a) != type(b) or type(a) == type(ccc)`
* We cannot assume `res == types.IntType` is wrong as the identity
of the objects is not known at check time, either way
it shouldn't be a E721 as it doesn't involve type(...) function
as described in PEP8
-rwxr-xr-x | pycodestyle.py | 1 | ||||
-rw-r--r-- | testsuite/E72.py | 4 |
2 files changed, 1 insertions, 4 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index c1ec98d..c71071e 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1465,7 +1465,6 @@ def comparison_type(logical_line, noqa): 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 e789d82..bba55f5 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 |