Skip to content

Commit 3d42db4

Browse files
committed
__iter__ and improved __repr__ for Fields
1 parent ff24fcb commit 3d42db4

File tree

1 file changed

+6
-3
lines changed
  • python-packages/smithy-python/smithy_python/_private/http

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ def __eq__(self, other: object) -> bool:
188188
return False
189189
return (
190190
self.name == other.name
191-
and self.kind == other.kind
191+
and self.kind is other.kind
192192
and self.value == other.value
193193
)
194194

195-
def __str__(self) -> str:
196-
return f"Field({self.kind.name} {self.name}: {self.get_value()})"
195+
def __repr__(self) -> str:
196+
return f'Field(name="{self.name}", value=[{self.value}], kind={self.kind})'
197197

198198

199199
class Fields(interfaces.http.Fields):
@@ -244,6 +244,9 @@ def __eq__(self, other: object) -> bool:
244244
return False
245245
return self.encoding == other.encoding and self.entries == other.entries
246246

247+
def __iter__(self):
248+
yield from self.entries
249+
247250

248251
@dataclass
249252
class Endpoint(interfaces.http.Endpoint):

0 commit comments

Comments
 (0)