diff --git a/isort/wrap_modes.py b/isort/wrap_modes.py index 6ea28018..b4ffd0ac 100644 --- a/isort/wrap_modes.py +++ b/isort/wrap_modes.py @@ -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"], diff --git a/tests/unit/test_wrap_modes.py b/tests/unit/test_wrap_modes.py index c21db904..b11b1e9b 100644 --- a/tests/unit/test_wrap_modes.py +++ b/tests/unit/test_wrap_modes.py @@ -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()),