Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions src/anthropic/_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ def _stringify_item(
if isinstance(value, (list, tuple)):
array_format = opts.array_format
if array_format == "comma":
return [
(
key,
",".join(self._primitive_value_to_str(item) for item in value if item is not None),
),
]
serialised = ",".join(self._primitive_value_to_str(item) for item in value if item is not None)
if not serialised:
return []
return [(key, serialised)]
elif array_format == "repeat":
items = []
for item in value:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def test_array_comma(method: str) -> None:
assert unquote(serialise({"in": ["foo", "bar"]})) == "in=foo,bar"
assert unquote(serialise({"a": {"b": [True, False]}})) == "a[b]=true,false"
assert unquote(serialise({"a": {"b": [True, False, None, True]}})) == "a[b]=true,false,true"
assert unquote(serialise({"a": []})) == ""
assert unquote(serialise({"a": [None]})) == ""
assert unquote(serialise({"a": {"b": []}})) == ""


def test_array_repeat() -> None:
Expand Down