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.
|
||||
normalize_prefix(leaves[0], inside_brackets=True)
|
||||
# Ensure a trailing comma when expected.
|
||||
if original.is_import and len(leaves) == 1:
|
||||
leaves.append(Leaf(token.COMMA, ","))
|
||||
if original.is_import:
|
||||
if leaves[-1].type != token.COMMA:
|
||||
leaves.append(Leaf(token.COMMA, ","))
|
||||
# Populate the line
|
||||
for leaf in leaves:
|
||||
result.append(leaf, preformatted=True)
|
||||
|
@ -79,6 +79,8 @@ Parsing
|
||||
Split functions
|
||||
---------------
|
||||
|
||||
.. autofunction:: black.bracket_split_build_line
|
||||
|
||||
.. autofunction:: black.bracket_split_succeeded_or_raise
|
||||
|
||||
.. 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.
|
||||
|
||||
__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__ = [
|
||||
|
@ -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:
|
||||
@pytest.mark.parametrize(
|
||||
("post_data", "message"),
|
||||
|
Loading…
Reference in New Issue
Block a user