Unverified Commit 1610fd6b authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Add trailing comma for single `as` imports, too

parent 0c5c5374
Loading
Loading
Loading
Loading
+2 −1
Changes for black.py: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2329,7 +2329,8 @@ def bracket_split_build_line(
            # Since body is a new indent level, remove spurious leading whitespace.
            normalize_prefix(leaves[0], inside_brackets=True)
            # Ensure a trailing comma when expected.
            if original.is_import and len(leaves) == 1:
            if original.is_import:
                if leaves[-1].type != token.COMMA:
                    leaves.append(Leaf(token.COMMA, ","))
    # Populate the line
    for leaf in leaves:
+2 −0
Changes for docs/reference/reference_functions.rst: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ Parsing
Split functions
---------------

.. autofunction:: black.bracket_split_build_line

.. autofunction:: black.bracket_split_succeeded_or_raise

.. autofunction:: black.delimiter_split
+14 −0
Changes for tests/data/comments2.py: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
    MyLovelyCompanyTeamProjectComponent  # NOT DRY
)
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
    MyLovelyCompanyTeamProjectComponent as component  # DRY
)

# Please keep __all__ alphabetized within each category.

__all__ = [
@@ -148,6 +155,13 @@ def inline_comments_in_brackets_ruin_everything():
# output


from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
    MyLovelyCompanyTeamProjectComponent,  # NOT DRY
)
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
    MyLovelyCompanyTeamProjectComponent as component,  # DRY
)

# Please keep __all__ alphabetized within each category.

__all__ = [
+8 −0
Changes for tests/data/comments4.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
    MyLovelyCompanyTeamProjectComponent,  # NOT DRY
)
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
    MyLovelyCompanyTeamProjectComponent as component,  # DRY
)


class C:
    @pytest.mark.parametrize(
        ("post_data", "message"),