Skip to content

Commit

Permalink
Fix stylish logix
Browse files Browse the repository at this point in the history
  • Loading branch information
remortalite committed Jun 26, 2024
1 parent f2e97be commit 35b6fd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gendiff/formatters/stylish.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def prepare_value(value):
if isinstance(value, dict):
return "{"
return ""
elif isinstance(value, bool):
return str(value).lower()
elif value is None:
Expand Down Expand Up @@ -35,7 +35,9 @@ def iter_(current_data, level=1):

nested_result = iter_(current_data[key],
level + 1)

if nested_result:
result[-1] += "{"
result.extend(nested_result)

result.append(f"{indent}{SHIFT_SIZE * INDENT_SYMBOL}}}")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_stylish.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def file1_2_nested_str():
return data


@pytest.mark.parametrize("test_input,expected", [({"name": "value"}, "{"),
@pytest.mark.parametrize("test_input,expected", [({"name": "value"}, ""),
(True, "true"),
(False, "false"),
(None, "null"),
({}, "{")])
({}, "")])
def test_prepare_value(test_input, expected):
assert prepare_value(test_input) == expected

Expand Down

0 comments on commit 35b6fd7

Please sign in to comment.