Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E721: type comparison is partially working #946

Closed
pmeier opened this issue Jun 26, 2020 · 2 comments
Closed

E721: type comparison is partially working #946

pmeier opened this issue Jun 26, 2020 · 2 comments

Comments

@pmeier
Copy link

pmeier commented Jun 26, 2020

Related to the discussion in #882 if type equality or identity comparisons should be allowed.

Consider the following snippet run with pycodestyle==2.6.0 on python==3.6:

def foo():
    return 0


def bar():
    return 1


assert type(foo()) == type(bar())
assert type(foo()) is type(bar())

foz = foo()
baz = bar()

assert type(foz) == type(baz)
assert type(foz) is type(baz)
foobar.py:9:20: E721 do not compare types, use 'isinstance()'
foobar.py:10:20: E721 do not compare types, use 'isinstance()'

It complains only for the first two assertions. If I'm not mistaken this means that either:

  • type comparisons are allowed, but are not registered properly if one does not compare variables or
  • type comparisons should still be not allowed, but are by accident.
@sigmavirus24
Copy link
Member

In the future, please search closed and open issues before creating new ones that are duplicates. The issue right below you on the issue list is literally a duplicate of this: #945

@pmeier
Copy link
Author

pmeier commented Jun 26, 2020

@sigmavirus24

In the future, please search closed and open issues before creating new ones that are duplicates.

I did and this is how I discovered #882. As far as I understand the discussion there, only workarounds exist for this problem. Thus, I was even more surprised to find that one "style" above checks fine while the other fails.

The issue right below you on the issue list is literally a duplicate of this: #945

Maybe it is related, but from my perspective its definitively not a duplicate. #945 is specifically about how to handle None for E721, which is not part of the problem I described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants