This commit is contained in:
lz_db
2025-11-16 12:31:03 +08:00
commit 0fab423a18
1451 changed files with 743213 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
from typing import (
Any,
)
def abbr(value: Any, limit: int = 79) -> str:
"""
Converts a value into its string representation and abbreviates that
representation based on the given length `limit` if necessary.
"""
rep = repr(value)
if len(rep) > limit:
if limit < 3:
raise ValueError("Abbreviation limit may not be less than 3")
rep = rep[: limit - 3] + "..."
return rep