-
Notifications
You must be signed in to change notification settings - Fork 890
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
extend CONTINUATION_ALIGN_STYLE=FIXED for space indentation #774
Conversation
Great! It adds an unexpected linebreak before the return type annotation though: def _as_prolog_str_full(
value: Union[PlainOldData, List[Any], bool, str, int, Dict[Any, Any],
None, Exception]
) -> str:
"""Recursively turn an object into a Prolog term.""" I expected the |
This doesn't give the extra 4 spaces of indent on a continuation that I was hoping for. :( (I also saw the extra indent before ") -> str", which wasn't there before) |
Here is my excerpted input: def cvt_power(node: pytree.Base, ctx: Ctx) -> ast_cooked.Base:
"""power: [AWAIT] atom trailer* ['**' factor]"""
# Can appear on left of assignment
if (node.children[0].type == token.AWAIT or
(node.children[0].type == token.NAME and xcast(Leaf, node.children[0]).value == 'await')):
atom_child, *trailer_factor_children = node.children[1:]
else:
atom_child, *trailer_factor_children = node.children
def _convert(grammar: pgen2_grammar.Grammar,
raw_node: Tuple[int, str, Tuple[str, int, int],
Sequence[Union[Node, Leaf]]]) -> Union[Node, Leaf]:
"""Convert raw node information to a Node or Leaf instance.
"""
def _as_prolog_str_full(value: Union[PlainOldData, List[Any], bool, str, int,
Dict[Any, Any], None, Exception]) -> str:
"""Recursively turn an object into a Prolog term.""" and here is the output of yapf for both SPACE and VALIGN-RIGHT: def cvt_power(node: pytree.Base, ctx: Ctx) -> ast_cooked.Base:
"""power: [AWAIT] atom trailer* ['**' factor]"""
# Can appear on left of assignment
if (node.children[0].type == token.AWAIT or
(node.children[0].type == token.NAME and xcast(Leaf, node.children[0]).value == 'await')):
atom_child, *trailer_factor_children = node.children[1:]
else:
atom_child, *trailer_factor_children = node.children
def _convert(
grammar: pgen2_grammar.Grammar, raw_node: Tuple[int, str, Tuple[str, int, int],
Sequence[Union[Node, Leaf]]]
) -> Union[Node, Leaf]:
"""Convert raw node information to a Node or Leaf instance.
"""
def _as_prolog_str_full(
value: Union[PlainOldData, List[Any], bool, str, int, Dict[Any, Any], None, Exception]
) -> str:
"""Recursively turn an object into a Prolog term.""" and for FIXED, I got: def cvt_power(node: pytree.Base, ctx: Ctx) -> ast_cooked.Base:
"""power: [AWAIT] atom trailer* ['**' factor]"""
# Can appear on left of assignment
if (node.children[0].type == token.AWAIT or
(node.children[0].type == token.NAME and xcast(Leaf, node.children[0]).value == 'await')):
atom_child, *trailer_factor_children = node.children[1:]
else:
atom_child, *trailer_factor_children = node.children
def _convert(
grammar: pgen2_grammar.Grammar, raw_node: Tuple[int, str, Tuple[str, int, int],
Sequence[Union[Node, Leaf]]]
) -> Union[Node, Leaf]:
"""Convert raw node information to a Node or Leaf instance.
"""
def _as_prolog_str_full(
value: Union[PlainOldData, List[Any], bool, str, int, Dict[Any, Any], None, Exception]
) -> str:
"""Recursively turn an object into a Prolog term.""" And here is my style:
|
I think you should set continuation_indent_width=8 to get the extra level of indentation with fixed continuation align style.
|
Hmmm ... continuation_indent_width=8 didn't do what I wanted some time in the past, but now it does. Thank-you! (With my .style.yapf, I don't see any difference with or without this patch; it doesn't add the extra line break for ") -> str" that @andreasvc noted.) |
I will rework this PR to solve the extra line break issue. Thank you for helping me test this PR. |
FYI: I'm not sure your PR was to blame; I compared against the latest release. |
This PR make
CONTINUATION_ALIGN_STYLE=FIXED
option available for indenting with space.Ref: #769