fix impl unwrap block #2207#3115
Open
asukaminato0721 wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an “Unwrap block” refactor code action to the Pyrefly LSP, enabling users to remove an enclosing block statement (e.g., if, else, for/while without else, with) and reindent the block body into the parent scope.
Changes:
- Implemented
unwrap_blockquick-fix/refactor logic, including AST traversal and text edit construction. - Wired the new refactor into
Transactionand the non-wasm LSP server’s code-action collection. - Added initial LSP code-action tests for unwrap-block (basic
if,else, and loop-else rejection).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyrefly/lib/test/lsp/code_actions.rs |
Adds unwrap-block helpers and a few targeted tests. |
pyrefly/lib/state/lsp/quick_fixes/unwrap_block.rs |
New unwrap-block refactor implementation (target detection + edit generation). |
pyrefly/lib/state/lsp/quick_fixes/mod.rs |
Exposes the new unwrap_block module. |
pyrefly/lib/state/lsp.rs |
Adds Transaction::unwrap_block_code_actions API entrypoint. |
pyrefly/lib/lsp/non_wasm/server.rs |
Includes unwrap-block in refactor code-action computation/telemetry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
connernilsen
requested changes
Apr 17, 2026
connernilsen
left a comment
Contributor
There was a problem hiding this comment.
Hey @asukaminato0721, this is looking good, but a few things (mostly requests for more tests). Let me know if you have questions
683994e to
502de9b
Compare
This comment has been minimized.
This comment has been minimized.
connernilsen
requested changes
Apr 20, 2026
92200b6 to
c4f23e6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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
part of #2207
impl unwrap block
astral-sh/ruff#24552
Test Plan
add test