-
Notifications
You must be signed in to change notification settings - Fork 18
(fix) Proposing a workaround for superfluous indentation on multi-lines #66
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
Open
MementoRC
wants to merge
8
commits into
isidentical:main
Choose a base branch
from
MementoRC:fix/indentation_ast_unpasre
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6456451
(fix) Proposing a workaround for superfluous indentation on multi-lines
MementoRC 73d5bba
(fix) Proposing a workaround for superfluous indentation on multi-lines
MementoRC 5193eb7
Fix for multi-line F-string
MementoRC 89ee04d
Addressing the feedback from review
MementoRC caeacad
Suggested simplification
MementoRC 8e8025b
Correcting bad tests and adding the possibility for the replacement t…
MementoRC 8bd25fc
Removing spurious changes (odd indentation)
MementoRC 2efaa1e
Adding specific testcase from Issue #12
MementoRC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we reduce it to bare minimum (let's drop the multiline strings for now, just to make this patch simpler), what this does is basically checking if the original line starts with the replaced line and if it is the case we skip indenting?
A better way to express it might be this:
But I am still unsure on how this should work in different scenarios, would love to see a few more examples (or actually tests) where the indentation is preserved for the first argument (when replacing the whole call), the middle arguments, the last argument (maybe introduce a new argument or remove one from the middle).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only works when the
Callis unchanged, removing or adding arguments does not maintain the original form, but collapses theCallinto one line. The case I was working with was wrapping theCallinAwaitand it works well in that caseThere is something I don't understand though, I added a few tests (bear with my padawan-level) and the Issue #12 pass, but in the complete_rules it does not, it'd be great if you took a look at those tests, I must be doing something (or more) incorrectly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the issue was that in the
test_ast.py, I use the full source_lines (with indent=0 and thus is not added to the failing line), but in thetest_complete_rules.pyonly the changed source line is passed (because of theview), so the indentation is there and the test fails.Now, the 'multi-line' issue is more of a "within parens" issue, so would it be acceptable to just have this:
elif original_line is not None and (original_line.startswith(line) or line[-1] in (")}]")):This way the test passes