Skip to content

Commit

Permalink
refactor todo repr function
Browse files Browse the repository at this point in the history
  • Loading branch information
mecaneer23 committed Oct 4, 2023
1 parent 95fb837 commit ec1f711
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/class_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ def dedent(self) -> None:
self.text = repr(self)

def __repr__(self) -> str:
return "".join(
[
self.indent_level * " ",
"" if self.box_char is None or self.is_empty() else self.box_char,
str(self.color) if self.color != 7 else "",
""
if (self.box_char is None or self.is_empty()) and self.color == 7
else " ",
self.display_text,
]
chunks: tuple[tuple[bool, str], ...] = (
(True, self.indent_level * " "),
(self.box_char is not None and not self.is_empty(), str(self.box_char)),
(self.color != 7, str(self.color)),
(
(self.box_char is not None and not self.is_empty()) or self.color != 7,
" ",
),
(True, self.display_text),
)
return "".join([item for condition, item in chunks if condition])

0 comments on commit ec1f711

Please sign in to comment.