Don't insert trailing commas after standalone comments
This commit is contained in:
parent
fcaaf955be
commit
4787294622
5
black.py
5
black.py
@ -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
|
||||
|
@ -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"""
|
||||
^
|
||||
|
Loading…
Reference in New Issue
Block a user