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

UP038 documentation outdated wrt. fix safety #13051

Open
VeckoTheGecko opened this issue Aug 22, 2024 · 3 comments
Open

UP038 documentation outdated wrt. fix safety #13051

VeckoTheGecko opened this issue Aug 22, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@VeckoTheGecko
Copy link

VeckoTheGecko commented Aug 22, 2024

Docs mention "Fix is always available." but it is flagged as unsafe in the code

ruff --version
ruff 0.6.1

Code

with isinstance(2, (int,float)) I get

test.py:1:1: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
  |
1 | isinstance(2, (int, float))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
  |
  = help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

Related to #2923

@MichaReiser
Copy link
Member

MichaReiser commented Aug 22, 2024

Thanks for opening this issue. I can see how this is confusing. I was actually just about to change the rule metadata but then noticed that, maybe I shouldn't.

The documentation's fix availability doesn't consider the fix's safety today, which makes sense because the fix is always available when using --unsafe-fixes. But I can see how this isn't very clear, especially with the CLI message that explicitly states that the fix is unavailable.

@zanieb what's your take on fix availability and fix safety?

@VeckoTheGecko
Copy link
Author

I see, so availability != safety (where I assumed it did). If safety was also mentioned in the doc that would have cleared it up (e.g., Fix is always available but not always safe)

@MichaReiser MichaReiser added the documentation Improvements or additions to documentation label Aug 22, 2024
@dhruvmanila
Copy link
Member

Yeah, I think it might be useful to add some reference to fix safety in the rule header. It might also be useful to either provide a different icon or a different color to the fix icon in the rules table (https://docs.astral.sh/ruff/rules/#legend).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants