truncate: strip trailing whitespace

This commit is contained in:
Lukáš Kucharczyk 2024-11-13 21:07:26 +01:00
parent 7181b6472c
commit 5c5fd5f26a
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@ def safe_getattr(obj: object, attr_chain: str, default: Any | None = None) -> ob
def truncate(input_string: str, length: int = 30, ellipsis: str = "") -> str:
return (
(f"{input_string[:length-len(ellipsis)]}{ellipsis}")
(f"{input_string[:length-len(ellipsis)].rstrip()}{ellipsis}")
if len(input_string) > length
else input_string
)