Break global and nonlocal statements over continuation lines#6172
Merged
charliermarsh merged 1 commit intomainfrom Aug 2, 2023
Merged
Break global and nonlocal statements over continuation lines#6172charliermarsh merged 1 commit intomainfrom
charliermarsh merged 1 commit intomainfrom
Conversation
Contributor
PR Check ResultsBenchmarkLinuxWindows |
161ed4a to
066f371
Compare
6674125 to
13f2d96
Compare
MichaReiser
approved these changes
Jul 31, 2023
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Looks good. It may now be worth factoring the shared logic into a shared Format* utility where you pass the keyword text and the names.
Member
|
We should lobby for def f():
global ( # noqa
analyze_featuremap_layer,
analyze_featuremapcompression_layer,
analyze_latencies_post,
analyze_motions_layer,
analyze_size_model
)to become valid python syntax. It's inconsistent that some nodes aren't allowed parentheses, while expressions might be wrapped in an arbitrary number of them.
This is currently a pervasive problem in the formatter. I'm not sure if special casing here is worth it. |
konstin
approved these changes
Jul 31, 2023
13f2d96 to
d67178f
Compare
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
Builds on #6170 to break
globalandnonlocalstatements, such that we get:Instead of:
Notably, we avoid applying this formatting if the statement ends in a comment. Otherwise, the comment would need to be placed after the last item, like:
To me, this seems wrong (and would break the
# noqacomment). Ideally, the items would be parenthesized, and the comment would be on the inner parenthesis, like:But that's not valid syntax.