-
Notifications
You must be signed in to change notification settings - Fork 892
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 argument assignment #1031
base: main
Are you sure you want to change the base?
Conversation
🙏🏻 |
The lack of the features you've implemented are the reason why I don't use formatters. Thank you! |
I left a comment on the original issue saying hope it gets attention of reviewers. It is frustrating to see no reviewers picked those PRs up yet for 3 months. |
Bumping this! Love this feature, really want to use it! |
@lizawang Since the devs seem quite slow to merge these PRs, would you make a branch in your fork that integrates them all or would you assist me in doing so? |
|
@lizawang I downloaded your "feature_align_assignment_and_dictColon" branch. I'm trying to build your branched version of yapf so that I can use it instead on my Windows-based machine. I've executed "python setup.py build", but I don't see a yapf.exe built. Do you know how I can build yapf.exe and then install it locally -- or a guide that shows how this is done for python projects in general? Many thanks! |
Bump! This has been long long wanted from many users. Thanks! |
thank you ! |
Hello all yapf founders!
I have some new features I want to share with the yapf community.
This is also a response to issue #194 and issue #346.
The alignment feature added is referred to the yapf function _AlignTrailingComments(final_lines).
The knobs
The main functions for all the knobs are added in reformatter.py.
knob: ALIGN_ARGUMENT_ASSIGNMENT
This is an option to align the assignment operators of each block inside the argument list of a function call or a function definition.
The condition : it is only effective if all arguments inside the argument list are placed on separate lines.
The case when the typed argument name is too long that it has newlines, we can increase the column limit, otherwise it will be aligned with the last line of the unwrapped typed argument name that has the assignment operator:
New block of arguments starts with new alignment. There are 3 cases featured as an indication for new alignment block:
knob: NEW_ALIGNMENT_AFTER_COMMENTLINE
This option is made under the consideration that some programmers may prefer to remain the alignment with comment lines inside.
Preparations
To make the alignment functions possible, some other changes are made to other files.
subtype_assigner.py: a change is made to include the subtype TYPED_NAME_ARG_LIST to all tokens inside typed argument name. This is to recognize all tokens before '=' of very long typed name in arguments with typed names, e.g., a typed argument as below:
format_token.py: necessary boolean functions are added, is_argassign, is_argname, is_argname_start.
Finally
In the end, the knobs are added into the style.py and tests for each one are also updated in yapftests folder.