[pyupgrade] Add resource.error as deprecated alias of OSError (UP024)#17933
[pyupgrade] Add resource.error as deprecated alias of OSError (UP024)#17933ntBre merged 3 commits intoastral-sh:mainfrom
pyupgrade] Add resource.error as deprecated alias of OSError (UP024)#17933Conversation
|
6bfdc7b to
f1da146
Compare
ntBre
left a comment
There was a problem hiding this comment.
Nice, this makes sense to me! For a test, you'll want to add a new UP024 test fixture like this:
It looks like UP024_5.py is the next available name (I linked to 3 since it's a bit more minimal of an example than 4).
And then you can add a new test_case here:
ruff/crates/ruff_linter/src/rules/pyupgrade/mod.rs
Lines 48 to 53 in ec2fdad
That should be all you need to generate new snapshots, which you can update with cargo-insta. The prerequisites section in the CONTRIBUTING.md file has some links for setting that up, if you need it. I'm happy to help if you run into any issues! I think this is good to go once we have a simple test case :)
f1da146 to
0bffb6b
Compare
|
I chose to modify the existing test instead: Unfortunately, the whole toolchain eats too much disk space, I cannot run tests on my computer. I'll try on a machine with more disk space next week. |
0bffb6b to
3f722c4
Compare
|
Thanks for adding the tests. Let me know if you want me to update the snapshots for you. |
3f722c4 to
6f50ce7
Compare
|
Snapshots updated. |
pyupgrade] Add resource.error as deprecated alias of OSError (UP024)
…`UP024`) (astral-sh#17933) ## Summary Partially addresses astral-sh#17935. [`resource.error`](https://docs.python.org/3/library/resource.html#resource.error) is a deprecated alias of [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError). > _Changed in version 3.3:_ Following [**PEP 3151**](https://peps.python.org/pep-3151/), this class was made an alias of [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError). Add it to the list of `OSError` aliases found by [os-error-alias (UP024)](https://docs.astral.sh/ruff/rules/os-error-alias/#os-error-alias-up024). ## Test Plan Sorry, I usually don't program in Rust. Could you at least point me to the test I would need to modify?
Summary
Partially addresses #17935.
resource.erroris a deprecated alias ofOSError.Add it to the list of
OSErroraliases found by os-error-alias (UP024).Test Plan
Sorry, I usually don't program in Rust. Could you at least point me to the test I would need to modify?