[pyupgrade] Better messages and diagnostic range (UP015)#15872
Merged
MichaReiser merged 2 commits intoastral-sh:mainfrom Feb 5, 2025
Merged
[pyupgrade] Better messages and diagnostic range (UP015)#15872MichaReiser merged 2 commits intoastral-sh:mainfrom
pyupgrade] Better messages and diagnostic range (UP015)#15872MichaReiser merged 2 commits intoastral-sh:mainfrom
Conversation
Contributor
Author
|
Is it necessary to add a "Preview" section to the rule documentation? |
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| UP015 | 110 | 55 | 55 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+55 -55 violations, +0 -0 fixes in 3 projects; 52 projects unchanged)
binary-husky/gpt_academic (+46 -46 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
- check_proxy.py:161:14: UP015 [*] Unnecessary open mode parameters + check_proxy.py:161:32: UP015 [*] Unnecessary mode argument - check_proxy.py:191:14: UP015 [*] Unnecessary open mode parameters + check_proxy.py:191:32: UP015 [*] Unnecessary mode argument - crazy_functions/Conversation_To_File.py:73:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/Conversation_To_File.py:73:30: UP015 [*] Unnecessary mode argument - crazy_functions/Conversation_To_File.py:87:10: UP015 [*] Unnecessary open mode parameters + crazy_functions/Conversation_To_File.py:87:26: UP015 [*] Unnecessary mode argument - crazy_functions/Latex_Project_Polish.py:66:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/Latex_Project_Polish.py:66:23: UP015 [*] Unnecessary mode argument - crazy_functions/Latex_Project_Translate_Legacy.py:46:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/Latex_Project_Translate_Legacy.py:46:23: UP015 [*] Unnecessary mode argument - crazy_functions/Markdown_Translate.py:61:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/Markdown_Translate.py:61:23: UP015 [*] Unnecessary mode argument - crazy_functions/SourceCode_Analyse.py:22:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/SourceCode_Analyse.py:22:23: UP015 [*] Unnecessary mode argument - crazy_functions/SourceCode_Comment.py:33:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/SourceCode_Comment.py:33:23: UP015 [*] Unnecessary mode argument - crazy_functions/SourceCode_Comment.py:79:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/SourceCode_Comment.py:79:76: UP015 [*] Unnecessary mode argument - crazy_functions/agent_fns/python_comment_agent.py:207:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/agent_fns/python_comment_agent.py:207:25: UP015 [*] Unnecessary mode argument - crazy_functions/ast_fns/comment_remove.py:48:10: UP015 [*] Unnecessary open mode parameters + crazy_functions/ast_fns/comment_remove.py:48:28: UP015 [*] Unnecessary mode argument - crazy_functions/latex_fns/latex_actions.py:239:10: UP015 [*] Unnecessary open mode parameters + crazy_functions/latex_fns/latex_actions.py:239:24: UP015 [*] Unnecessary mode argument - crazy_functions/latex_fns/latex_actions.py:322:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/latex_fns/latex_actions.py:322:29: UP015 [*] Unnecessary mode argument - crazy_functions/latex_fns/latex_actions.py:358:18: UP015 [*] Unnecessary open mode parameters + crazy_functions/latex_fns/latex_actions.py:358:33: UP015 [*] Unnecessary mode argument - crazy_functions/latex_fns/latex_toolbox.py:294:14: UP015 [*] Unnecessary open mode parameters + crazy_functions/latex_fns/latex_toolbox.py:294:25: UP015 [*] Unnecessary mode argument - crazy_functions/latex_fns/latex_toolbox.py:321:18: UP015 [*] Unnecessary open mode parameters + crazy_functions/latex_fns/latex_toolbox.py:321:29: UP015 [*] Unnecessary mode argument - crazy_functions/latex_fns/latex_toolbox.py:386:22: UP015 [*] Unnecessary open mode parameters + crazy_functions/latex_fns/latex_toolbox.py:386:32: UP015 [*] Unnecessary mode argument - crazy_functions/pdf_fns/parse_pdf_via_doc2x.py:250:18: UP015 [*] Unnecessary open mode parameters + crazy_functions/pdf_fns/parse_pdf_via_doc2x.py:250:37: UP015 [*] Unnecessary mode argument - crazy_functions/pdf_fns/parse_pdf_via_doc2x.py:269:18: UP015 [*] Unnecessary open mode parameters + crazy_functions/pdf_fns/parse_pdf_via_doc2x.py:269:37: UP015 [*] Unnecessary mode argument - crazy_functions/pdf_fns/parse_pdf_via_doc2x.py:298:18: UP015 [*] Unnecessary open mode parameters ... 51 additional changes omitted for project
latchbio/latch (+8 -8 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
- src/latch/executions.py:56:14: UP015 [*] Unnecessary open mode parameters + src/latch/executions.py:56:36: UP015 [*] Unnecessary mode argument - src/latch_cli/exceptions/traceback.py:24:14: UP015 [*] Unnecessary open mode parameters + src/latch_cli/exceptions/traceback.py:24:34: UP015 [*] Unnecessary mode argument - src/latch_cli/main.py:975:10: UP015 [*] Unnecessary open mode parameters + src/latch_cli/main.py:975:57: UP015 [*] Unnecessary mode argument - src/latch_cli/services/get_executions.py:377:14: UP015 [*] Unnecessary open mode parameters + src/latch_cli/services/get_executions.py:377:29: UP015 [*] Unnecessary mode argument - src/latch_cli/services/launch.py:48:10: UP015 [*] Unnecessary open mode parameters + src/latch_cli/services/launch.py:48:28: UP015 [*] Unnecessary mode argument ... 6 additional changes omitted for project
milvus-io/pymilvus (+1 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
- examples/bulk_import/example_bulkwriter.py:263:18: UP015 [*] Unnecessary open mode parameters + examples/bulk_import/example_bulkwriter.py:263:34: UP015 [*] Unnecessary mode argument
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| UP015 | 110 | 55 | 55 | 0 | 0 |
MichaReiser
approved these changes
Feb 3, 2025
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Thanks. A few small nits but overall this looks good
crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs
Outdated
Show resolved
Hide resolved
MichaReiser
approved these changes
Feb 5, 2025
MichaReiser
added a commit
that referenced
this pull request
Mar 13, 2025
…P015`) (#16672) ## Summary This PR stabilizes the behavior change introduced in #15872 The diagnostic range is now the range of the redundant `mode` argument where it previously was the range of the entire `open` call: Before: ``` UP015.py:2:1: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^^^^^^^^^^^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` Now: ``` UP015.py:2:13: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` This is a breaking change because it may require moving a `noqa` comment onto a different line, e.g if you have ```py open( "foo", "Ur", ) # noqa: UP015 ``` Needs to be rewritten to ```py open( "foo", "Ur", # noqa: UP015 ) ``` There have been now new issues or PRs since the new preview behavior was implemented. It first was released as part of Ruff 0.9.5 on the 5th of Feb (a little more than a month ago) ## Test Plan I reviewed the snapshot tests
MichaReiser
added a commit
that referenced
this pull request
Mar 13, 2025
…P015`) (#16672) ## Summary This PR stabilizes the behavior change introduced in #15872 The diagnostic range is now the range of the redundant `mode` argument where it previously was the range of the entire `open` call: Before: ``` UP015.py:2:1: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^^^^^^^^^^^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` Now: ``` UP015.py:2:13: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` This is a breaking change because it may require moving a `noqa` comment onto a different line, e.g if you have ```py open( "foo", "Ur", ) # noqa: UP015 ``` Needs to be rewritten to ```py open( "foo", "Ur", # noqa: UP015 ) ``` There have been now new issues or PRs since the new preview behavior was implemented. It first was released as part of Ruff 0.9.5 on the 5th of Feb (a little more than a month ago) ## Test Plan I reviewed the snapshot tests
MichaReiser
added a commit
that referenced
this pull request
Mar 13, 2025
…P015`) (#16672) ## Summary This PR stabilizes the behavior change introduced in #15872 The diagnostic range is now the range of the redundant `mode` argument where it previously was the range of the entire `open` call: Before: ``` UP015.py:2:1: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^^^^^^^^^^^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` Now: ``` UP015.py:2:13: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` This is a breaking change because it may require moving a `noqa` comment onto a different line, e.g if you have ```py open( "foo", "Ur", ) # noqa: UP015 ``` Needs to be rewritten to ```py open( "foo", "Ur", # noqa: UP015 ) ``` There have been now new issues or PRs since the new preview behavior was implemented. It first was released as part of Ruff 0.9.5 on the 5th of Feb (a little more than a month ago) ## Test Plan I reviewed the snapshot tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #15863.
In preview, diagnostic ranges will now be limited to that of the argument. Rule documentation, variable names, error messages and fix titles have all been modified to use "argument" consistently.
Test Plan
cargo nextest runandcargo insta test.