diff --git a/isort/wrap_modes.py b/isort/wrap_modes.py index b7b22f000..ccfc1cd5a 100644 --- a/isort/wrap_modes.py +++ b/isort/wrap_modes.py @@ -60,11 +60,11 @@ def grid(**interface): len(next_statement.split(interface["line_separator"])[-1]) + 1 > interface["line_length"] ): - lines = [f"{white_space}{next_import.split(' ')[0]}"] + lines = [f"{interface['white_space']}{next_import.split(' ')[0]}"] for part in next_import.split(" ")[1:]: new_line = f"{lines[-1]} {part}" if len(new_line) + 1 > interface["line_length"]: - lines.append(f"{white_space}{part}") + lines.append(f"{interface['white_space']}{part}") else: lines[-1] = new_line next_import = interface["line_separator"].join(lines) diff --git a/tests/unit/test_wrap_modes.py b/tests/unit/test_wrap_modes.py index 7d6fbb0c7..c95a75136 100644 --- a/tests/unit/test_wrap_modes.py +++ b/tests/unit/test_wrap_modes.py @@ -73,16 +73,24 @@ def test_backslash_grid(): """Tests the backslash_grid grid wrap mode, ensuring it matches formatting expectations. See: https://github.com/PyCQA/isort/issues/1434 """ - assert isort.code(""" + assert ( + isort.code( + """ from kopf.engines import loggers, posting from kopf.reactor import causation, daemons, effects, handling, lifecycles, registries from kopf.storage import finalizers, states from kopf.structs import (bodies, configuration, containers, diffs, handlers as handlers_, patches, resources) -""", multi_line_output=11, line_length=88, combine_as_imports=True) == """ +""", + multi_line_output=11, + line_length=88, + combine_as_imports=True, + ) + == """ from kopf.engines import loggers, posting from kopf.reactor import causation, daemons, effects, handling, lifecycles, registries from kopf.storage import finalizers, states from kopf.structs import bodies, configuration, containers, diffs, \\ handlers as handlers_, patches, resources """ + )