Add trailing comma for single as
imports, too
This commit is contained in:
parent
0c5c537431
commit
1610fd6bc5
5
black.py
5
black.py
@ -2329,8 +2329,9 @@ def bracket_split_build_line(
|
|||||||
# Since body is a new indent level, remove spurious leading whitespace.
|
# Since body is a new indent level, remove spurious leading whitespace.
|
||||||
normalize_prefix(leaves[0], inside_brackets=True)
|
normalize_prefix(leaves[0], inside_brackets=True)
|
||||||
# Ensure a trailing comma when expected.
|
# Ensure a trailing comma when expected.
|
||||||
if original.is_import and len(leaves) == 1:
|
if original.is_import:
|
||||||
leaves.append(Leaf(token.COMMA, ","))
|
if leaves[-1].type != token.COMMA:
|
||||||
|
leaves.append(Leaf(token.COMMA, ","))
|
||||||
# Populate the line
|
# Populate the line
|
||||||
for leaf in leaves:
|
for leaf in leaves:
|
||||||
result.append(leaf, preformatted=True)
|
result.append(leaf, preformatted=True)
|
||||||
|
@ -79,6 +79,8 @@ Parsing
|
|||||||
Split functions
|
Split functions
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
.. autofunction:: black.bracket_split_build_line
|
||||||
|
|
||||||
.. autofunction:: black.bracket_split_succeeded_or_raise
|
.. autofunction:: black.bracket_split_succeeded_or_raise
|
||||||
|
|
||||||
.. autofunction:: black.delimiter_split
|
.. autofunction:: black.delimiter_split
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
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.
|
# Please keep __all__ alphabetized within each category.
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
@ -148,6 +155,13 @@ def inline_comments_in_brackets_ruin_everything():
|
|||||||
# output
|
# 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.
|
# Please keep __all__ alphabetized within each category.
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
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:
|
class C:
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("post_data", "message"),
|
("post_data", "message"),
|
||||||
|
Loading…
Reference in New Issue
Block a user