From 013b014bdaa3bfba263037d6e70098c407e153fe Mon Sep 17 00:00:00 2001 From: Pavel Bitiukov Date: Sun, 22 Oct 2023 15:23:11 +0100 Subject: [PATCH] Removed check for include_trailing_comma for the Hanging Indent wrap mode --- isort/wrap_modes.py | 3 --- tests/unit/test_wrap_modes.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/isort/wrap_modes.py b/isort/wrap_modes.py index 6ea280187..b4ffd0ac7 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 c21db9049..b11b1e9bb 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()),