Don't insert trailing commas after standalone comments

This commit is contained in:
Łukasz Langa 2018-03-31 23:32:11 -07:00
parent fcaaf955be
commit 4787294622
2 changed files with 18 additions and 2 deletions

View File

@ -1796,9 +1796,10 @@ def append_to_line(leaf: Leaf) -> Iterator[Line]:
current_line = Line(depth=line.depth, inside_brackets=line.inside_brackets)
if current_line:
if (
delimiter_priority == COMMA_PRIORITY
trailing_comma_safe
and delimiter_priority == COMMA_PRIORITY
and current_line.leaves[-1].type != token.COMMA
and trailing_comma_safe
and current_line.leaves[-1].type != STANDALONE_COMMENT
):
current_line.append(Leaf(token.COMMA, ","))
yield current_line

View File

@ -47,6 +47,12 @@ def long_lines():
typedargslist.extend(
gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
)
typedargslist.extend(
gen_annotated_params(
ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True,
# trailing standalone comment
)
)
_type_comment_re = re.compile(
r"""
^
@ -161,6 +167,15 @@ def long_lines():
implicit_default=True,
)
)
typedargslist.extend(
gen_annotated_params(
ast_args.kwonlyargs,
ast_args.kw_defaults,
parameters,
implicit_default=True,
# trailing standalone comment
)
)
_type_comment_re = re.compile(
r"""
^