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

E712 : Wrong fix suggested in presence of numpy.bool_ #4356

Closed
kesinger-idexx opened this issue May 10, 2023 · 1 comment
Closed

E712 : Wrong fix suggested in presence of numpy.bool_ #4356

kesinger-idexx opened this issue May 10, 2023 · 1 comment

Comments

@kesinger-idexx
Copy link

Using ruff 0.0.265.

In this code, the two if-blocks are NOT equivalent:

def f(x):
    # x is a np.ndarray with at least 2 dimensions
    return x[0, 0] > 0

x = np.eye(2)
a = f(x)
if a == True:
    print("a==True")
if a is True:
    print("a is True")
    assert(False)

What's going on is type(a)==numpy.bool_ which can be compared to True/False via == but it is not referentially the same.

@zanieb
Copy link
Member

zanieb commented May 10, 2023

Duplicate of #2443

I'll make a tracking issue for all is/== problems

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2023
MichaReiser pushed a commit that referenced this issue Jul 27, 2023
Fix parsing of tuple with named expression as context manager
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

3 participants