Skip to content

Incorrect report of chained-comparison #10338

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

Closed
Lucas-C opened this issue Apr 11, 2025 · 2 comments
Closed

Incorrect report of chained-comparison #10338

Lucas-C opened this issue Apr 11, 2025 · 2 comments

Comments

@Lucas-C
Copy link
Contributor

Lucas-C commented Apr 11, 2025

Bug description

from types import SimpleNamespace

ns = SimpleNamespace()
ns.x = 0
ns.y = 10

if ns.x >= 2 and ns.y < 2:
    pass

Command used

pylint pylint_bugrepro.py

Pylint output

************* Module pylint_bugrepro
pylint_bugrepro.py:7:3: R1716: Simplify chained comparison between the operands (chained-comparison)

Expected behavior

Nothing reported by Pylint

Pylint version

3.3.6 (latest at this time)

OS / Environment

WSL 2 - Ubuntu 22 LTS

@Lucas-C Lucas-C added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 11, 2025
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Apr 11, 2025

Can't it be simplified as if ns.x >= 2 > ns.y or if ns.y < 2 <= ns.x ?

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Apr 11, 2025

This is a strange "simplification", but alright, if this is what's expected...

@Pierre-Sassoulas Pierre-Sassoulas added Won't fix/not planned and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 11, 2025
@Pierre-Sassoulas Pierre-Sassoulas closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants