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

approx equal can be more restricted than == #13218

Open
yuyichao opened this issue Feb 12, 2025 · 0 comments
Open

approx equal can be more restricted than == #13218

yuyichao opened this issue Feb 12, 2025 · 0 comments

Comments

@yuyichao
Copy link

This is similar to #13047 but is broader than that. In fact, the current PR that fixes that issue will only cause similar issues between other types. I'm very surprised that such major behavioral change may be introduced as a bug fix in a patch release.....

While I think it's wrong to make such change in a patch release, I do agree with using more exact comparison for boolean types. However, it seems over restricted when comparison using normal == produces True.

In [2]: 1 == pytest.approx(True)
Out[2]: False

In [3]: 1.0 == pytest.approx(True)
Out[3]: False

In [4]: 1.0 == True
Out[4]: True

In [5]: 1 == True
Out[5]: True

This makes the behavior of approx a bit difficult to reason about. I doubt if anyone would be asking for a more restricted comparison by adding approx...

yuyichao added a commit to euriqa-brassboard/brassboard-seq that referenced this issue Feb 12, 2025
Also fix list comparison that was only comparing the first element...

Ref pytest-dev/pytest#9354
Ref pytest-dev/pytest#13218
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

1 participant