Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,23 +2062,15 @@ def format_attribute(val: "Any") -> "AttributeValue":
if isinstance(val, (bool, int, float, str)):
return val

# Only lists of elements of a single type are supported
list_types: 'dict[type, Literal["string[]", "integer[]", "double[]", "boolean[]"]]' = {
str: "string[]",
int: "integer[]",
float: "double[]",
bool: "boolean[]",
}

if isinstance(val, (list, tuple)) and not val:
return []
elif isinstance(val, list):
ty = type(val[0])
if ty in list_types and all(type(v) is ty for v in val):
if ty in (str, int, float, bool) and all(type(v) is ty for v in val):
return copy.deepcopy(val)
elif isinstance(val, tuple):
ty = type(val[0])
if ty in list_types and all(type(v) is ty for v in val):
if ty in (str, int, float, bool) and all(type(v) is ty for v in val):
return list(val)

return safe_repr(val)
Expand Down
Loading