-
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
Replace verbatim text with NOT_YET_IMPLEMENTED
#4904
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
x = 0O777 .real | ||
x = 0.000000006 .hex() | ||
x = -100.0000J | ||
NOT_YET_IMPLEMENTED_StmtAssign |
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.
An added benefit of this change is that it is easier to spot what formatting is implemented and what is incorrectly formatted because it is not yet supported.
a7c1782
to
a55ccd8
Compare
|
||
|
||
three_leading_newlines = 80 | ||
NOT_YET_IMPLEMENTED_StmtAssign |
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.
I agree, this is stupid... but it is how it is.
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
b2ec055
to
f23ff61
Compare
a55ccd8
to
59c3e35
Compare
@MichaReiser started a stack merge that includes this pull request via Graphite. |
Graphite rebased this pull request as part of a merge. |
59c3e35
to
48ce57f
Compare
@MichaReiser merged this pull request with Graphite. |
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary This PR replaces the `verbatim_text` builder with a `not_yet_implemented` builder that emits `NOT_YET_IMPLEMENTED_<NodeKind>` for not yet implemented nodes. The motivation for this change is that partially formatting compound statements can result in incorrectly indented code, which is a syntax error: ```python def func_no_args(): a; b; c if True: raise RuntimeError if False: ... for i in range(10): print(i) continue ``` Get's reformatted to ```python def func_no_args(): a; b; c if True: raise RuntimeError if False: ... for i in range(10): print(i) continue ``` because our formatter does not yet support `for` statements and just inserts the text from the source. ## Downsides Using an identifier will not work in all situations. For example, an identifier is invalid in an `Arguments ` position. That's why I kept `verbatim_text` around and e.g. use it in the `Arguments` formatting logic where incorrect indentations are impossible (to my knowledge). Meaning, `verbatim_text` we can opt in to `verbatim_text` when we want to iterate quickly on nodes that we don't want to provide a full implementation yet and using an identifier would be invalid. ## Upsides Running this on main discovered stability issues with the newline handling that were previously "hidden" because of the verbatim formatting. I guess that's an upside :) ## Test Plan None?
Summary
This PR replaces the
verbatim_text
builder with anot_yet_implemented
builder that emitsNOT_YET_IMPLEMENTED_<NodeKind>
for not yet implemented nodes.The motivation for this change is that partially formatting compound statements can result in incorrectly indented code, which is a syntax error:
Get's reformatted to
because our formatter does not yet support
for
statements and just inserts the text from the source.Downsides
Using an identifier will not work in all situations. For example, an identifier is invalid in an
Arguments
position. That's why I keptverbatim_text
around and e.g. use it in theArguments
formatting logic where incorrect indentations are impossible (to my knowledge). Meaning,verbatim_text
we can opt in toverbatim_text
when we want to iterate quickly on nodes that we don't want to provide a full implementation yet and using an identifier would be invalid.Upsides
Running this on main discovered stability issues with the newline handling that were previously "hidden" because of the verbatim formatting. I guess that's an upside :)
Test Plan
None?