-
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 fix results in unsafe behavior #9063
Comments
Please see #4560 This fix should already be marked as unsafe and not applied unless you've opted into unsafe fixes e.g.
|
Hmm...sorry about that, I'll have to figure out how the auto fix got triggered, our pre-commit doesn't specify |
Hmm, could you have unsafe-fixes = true set in your pyproject.toml or ruff.toml file? |
No - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.6
hooks:
- id: ruff
name: "Lint and fix code using Ruff"
args: [ --fix, --exit-non-zero-on-fix ]
stages: [commit] Going to assume maybe someone triggered it manually to get it to stop complaining |
Hides hints about unsafe fixes when they are disabled e.g. with `--no-unsafe-fixes` or `unsafe-fixes = false`. By default, unsafe fix hints are still displayed. This seems like a nice way to remove the nag for users who have chosen not to apply unsafe fixes. Inspired by comment at #9063 (comment)
@DavidSlayback #9095 will be in our next release so you can disable unsafe fixes entirely to hide that complaint :) |
If Ruff is allowed to check for and fix E712 errors, this can result in unexpected behavior with things like pandas DataFrames. Example:
The original behavior produces a mask for each operand and combines them. The "fix" makes the first operand always return False, which means the whole mask is False.
Ruff version: v0.1.6
I think the desired behavior would be to either consider the fix unsafe or to favor removing
== True
and!= True
, but the latter might be difficult (because the correct equivalent to != in Pandas is~df
, not!df
ornot df
The text was updated successfully, but these errors were encountered: