Commit 47872946 authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Don't insert trailing commas after standalone comments

parent fcaaf955
Loading
Loading
Loading
Loading
+3 −2
Changes for black.py: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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
+15 −0
Changes for tests/function.py: 15 added lines, 0 removed lines.
Original line number Diff line number Diff 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"""
        ^