-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 (Comparison to True should be cond is True) should be ignored when comparison is against pandas.Series #1852
Comments
Pretty hard to avoid until we can infer that |
Can we prevent the autofix from applying this specific rule? |
The same problem happens in sqlalchemy queries ( |
Before I disable autofix for this rule entirely... you can disable it for your project via: [tool.ruff]
unfixable = ["E712"] Is that sufficient here? |
Works for me, thanks! :) |
In my data analysis and data science projects I end up ignoring this rule more often than having it autofixed, so I ended up using
instead. There are a few other cases where autofixing |
Yeah, that makes sense. I think I'm going to close this for now given that we have some workarounds (users should either disable the rule entirely, or, if they want the rule to be enabled but want to avoid false fixes, should use |
This just broke our code using SQLAlchemy converting
to
which it definitely shouldn't have autofixed. Can this instead be a suggestion provided but something that is not autofixed? Can prevent a lot of headaches. |
This is marked in the codebase as a "Suggested" autofix, which in a future release will require running with additional command-line flags to explicitly opt-in to fixing. |
using
ruff==0.0.215
The following snippet raises an E712 when running
ruff
:and the autofix replaces
df["x"] != False
withdf["x"] is not False
. The two are unfortunately not equivalent and the latter leads to errors from pandas.The text was updated successfully, but these errors were encountered: