Skip to content

Commit 73e2079

Browse files
committed
accept any iterable for field values in Field and fields in Fields
1 parent 8060ea4 commit 73e2079

File tree

1 file changed

+5
-4
lines changed
  • python-packages/smithy-python/smithy_python/_private/http

1 file changed

+5
-4
lines changed

python-packages/smithy-python/smithy_python/_private/http/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616

1717
from collections import Counter, OrderedDict
18+
from collections.abc import Iterable
1819
from dataclasses import dataclass, field
19-
from typing import Any, Iterable, Protocol
20+
from typing import Any, Protocol
2021
from urllib.parse import urlparse, urlunparse
2122

2223
from ... import interfaces
@@ -132,11 +133,11 @@ class Field(interfaces.http.Field):
132133
def __init__(
133134
self,
134135
name: str,
135-
value: list[str] | None = None,
136+
value: Iterable[str] | None = None,
136137
kind: FieldPosition = FieldPosition.HEADER,
137138
):
138139
self.name = name
139-
self.value: list[str] = value if value is not None else []
140+
self.value: list[str] = [val for val in value] if value is not None else []
140141
self.kind = kind
141142

142143
def add(self, value: str) -> None:
@@ -211,7 +212,7 @@ def quote_and_escape_field_value(value: str) -> str:
211212
class Fields(interfaces.http.Fields):
212213
def __init__(
213214
self,
214-
initial: list[interfaces.http.Field] | None = None,
215+
initial: Iterable[interfaces.http.Field] | None = None,
215216
*,
216217
encoding: str = "utf-8",
217218
):

0 commit comments

Comments
 (0)