-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Missing pyupgrade errors (UP006, UP035) #8698
Comments
Thank you for the kind words! I think this is a result of #3215 -- we stopped rewriting annotations that are used at runtime (roughly, on the right-hand side of an expression) because it can change behavior. #4843 has some more information. I think we actually can rewrite these in some but not all scenarios. In other words, our current approach is probably too conservative. |
I think it's always safe to perform these rewrites for UP006 (like It's probably not always safe to perform these rewrites for UP007 (which converts |
I think you should write this as a type alias: foo: TypeAlias = Type[list] # Python < 3.12
type foo = type[list] # Python >= 3.12 And then would it be possible for Ruff to make the transformation? Are right-hand-sides of type aliases okay? |
Aside from the issues with autofix, is there a reason not to provide the deprecation inspection? |
The only reason is to ensure we're not introducing false positives. So it'd be nice to make sure we have a sense for where this is and isn't safe prior to enabling the check for runtime annotations. |
Oh hmm, I'm actually noticing that if your Python version is set correctly, we do flag and fix this: https://play.ruff.rs/526e6c64-b8da-4cd5-8dcd-68ee71a6f886 Do you have your |
@charliermarsh No, I did not! Should have had that in my config (actually, should just up my |
Awesome, thanks @rademacher-p! Sorry for the confusion but glad to resolve. |
Hi, I seem to be missing pyupgrade errors for Python 3.11 and Ruff 0.1.5. Reproduce w/
ruff --isolated --select UP file.py
on a freshvenv
. This is all from the CLI, nopyproject.toml
.I ❤️
ruff
, thanks in advance for any help!The text was updated successfully, but these errors were encountered: