From 5727d06d92105c0001785b94af61f5c05e0b3b0b Mon Sep 17 00:00:00 2001 From: u8slvn Date: Thu, 11 Jul 2024 10:19:58 +0200 Subject: [PATCH] refactor: remove else in task details formatter --- src/hyperfocus/termui/formatter.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hyperfocus/termui/formatter.py b/src/hyperfocus/termui/formatter.py index 34ea28a..3834314 100644 --- a/src/hyperfocus/termui/formatter.py +++ b/src/hyperfocus/termui/formatter.py @@ -41,17 +41,18 @@ def task_details(value: str | None) -> str: return icons.EMPTY_DETAILS lines = value.splitlines() - if len(lines) > 1: - start, *middle, end = lines - start = f"{icons.MULTILINES_DETAILS_START} {start}" - middle = [f"{icons.MULTILINES_DETAILS_MIDDLE} {line}" for line in middle] - end = f"{icons.MULTILINES_DETAILS_END} {end}" - - return "\n" + "\n".join([start, *middle, end]) - else: + if len(lines) <= 1: return value + start, *middle, end = lines + + start = f"{icons.MULTILINES_DETAILS_START} {start}" + middle = [f"{icons.MULTILINES_DETAILS_MIDDLE} {line}" for line in middle] + end = f"{icons.MULTILINES_DETAILS_END} {end}" + + return "\n" + "\n".join([start, *middle, end]) + def stashed_task(old_task_id: int, task: Task) -> str: # TODO: find a way to merge with classic task formatter.