Skip to main content

truncate_safe_repr

No overview available.

def truncate_safe_repr(
obj: Any,
max_length: int = 100
) - > string

Returns a string representation of an object that is truncated to a maximum length to prevent excessive output in logs or error messages.

Parameters

NameTypeDescription
objAnyThe object to be converted into a string representation.
max_lengthint = 100The maximum number of characters allowed before the string is truncated.

Returns

TypeDescription
stringThe string representation of the object, truncated and appended with an ellipsis if it exceeds the maximum length.