Skip to content

Commit

Permalink
Merge pull request #2192 from bp72/issue/2174
Browse files Browse the repository at this point in the history
Removed check for include_trailing_comma for the Hanging Indent wrap mode
  • Loading branch information
staticdev authored Dec 4, 2023
2 parents f61affa + 013b014 commit 0118e90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 0 additions & 3 deletions isort/wrap_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ def hanging_indent(**interface: Any) -> str:
)
interface["statement"] = next_statement

interface[
"statement"
] = f"{interface['statement']}{',' if interface['include_trailing_comma'] else ''}"
if interface["comments"]:
statement_with_comments = isort.comments.add_to_line(
interface["comments"],
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_wrap_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,24 @@ def test_fuzz_hanging_indent(
reject()


@pytest.mark.parametrize("include_trailing_comma", (True, False))
def test_hanging_indent__with_include_trailing_comma__expect_same_result(include_trailing_comma):
result = isort.wrap_modes.hanging_indent(
statement="from datetime import ",
imports=["datetime", "time", "timedelta", "timezone", "tzinfo"],
white_space=" ",
indent=" ",
line_length=50,
comments=[],
line_separator="\n",
comment_prefix=" #",
include_trailing_comma=include_trailing_comma,
remove_comments=False,
)

assert result == "from datetime import datetime, time, timedelta, \\\n timezone, tzinfo"


@given(
statement=st.text(),
imports=st.lists(st.text()),
Expand Down

0 comments on commit 0118e90

Please sign in to comment.