-
Notifications
You must be signed in to change notification settings - Fork 896
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
Feature align assignment #1030
Open
lizawang
wants to merge
12
commits into
google:main
Choose a base branch
from
lizawang:feature_align_assignment
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.
+379
−2
Open
Feature align assignment #1030
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f62d929
features to align assignment operators and dictionary colons
lizawang 7a7de67
update the changelog and readme
lizawang 94cca9b
small fixes
lizawang 2ecde17
Update README.rst
lizawang e2181d8
fix readme
lizawang 4275bb7
fix readme
lizawang 82f1326
fix align_dict_colon
lizawang 6c273dc
add test for the case when the dict starts with a comment
lizawang db00217
branch for assignment alignment
lizawang beec868
run the assignment align over the yapf codes
lizawang aa3f8a7
change the format back to yapf-based
lizawang ad90616
change the format back to yapf-based 2
lizawang 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,61 @@ Options:: | |
Knobs | ||
===== | ||
|
||
``ALIGN_ASSIGNMENT`` | ||
Align assignment or augmented assignment operators. | ||
If there is a blank line or a newline comment or a multiline object | ||
(e.g. a dictionary, a list, a function call) in between, | ||
it will start new block alignment. Lines in the same block have the same | ||
indentation level. | ||
|
||
.. code-block:: python | ||
|
||
a = 1 | ||
abc = 2 | ||
if condition == None: | ||
var += '' | ||
var_long -= 4 | ||
b = 3 | ||
bc = 4 | ||
|
||
``ALIGN_ARGUMENT_ASSIGNMENT`` | ||
Align assignment operators in the argument list if they are all split on newlines. | ||
Arguments without assignment in between will initiate new block alignment calulation; | ||
for example, a comment line. | ||
Multiline objects in between will also initiate a new alignment block. | ||
|
||
.. code-block:: python | ||
|
||
rglist = test( | ||
var_first = 0, | ||
var_second = '', | ||
var_dict = { | ||
"key_1" : '', | ||
"key_2" : 2, | ||
"key_3" : True, | ||
}, | ||
var_third = 1, | ||
var_very_long = None ) | ||
|
||
``ALIGN_DICT_COLON`` | ||
Align the colons in the dictionary if all entries in dictionay are split on newlines | ||
or 'EACH_DICT_ENTRY_ON_SEPERATE_LINE' is set True. | ||
A commentline or multi-line object in between will start new alignment block. | ||
|
||
.. code-block:: python | ||
|
||
fields = | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This opening bracket should be on the first line. |
||
"field" : "ediid", | ||
"type" : "text", | ||
# key: value | ||
"required" : True, | ||
} | ||
|
||
``NEW_ALIGNMENT_AFTER_COMMENTLINE`` | ||
Make it optional to start a new alignmetn block for assignment | ||
alignment and colon alignment after a comment line. | ||
|
||
``ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT`` | ||
Align closing bracket with visual indentation. | ||
|
||
|
This file contains 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 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 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
Oops, something went wrong.
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.
Please reflow this to 80-columns.