Skip to content

Commit 83c6e99

Browse files
github-actions[bot]altescypquentin
authored
[Backport 8.11] Fix __iter__ return type to Iterator (#130)
* Fix __iter__ return type to Iterator (#129) Co-authored-by: Yasuhiro Yamaguchi <[email protected]> Co-authored-by: Quentin Pradet <[email protected]>
1 parent 22dbb3d commit 83c6e99

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

elastic_transport/_response.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
Any,
2020
Dict,
2121
Generic,
22-
Iterable,
2322
Iterator,
2423
List,
2524
NoReturn,
@@ -107,8 +106,8 @@ def __setstate__(self, state: Tuple[_BodyType, ApiResponseMeta]) -> None:
107106
def __len__(self) -> int:
108107
return len(self._body)
109108

110-
def __iter__(self) -> Iterable[Any]:
111-
return iter(self._body) # type: ignore[no-any-return]
109+
def __iter__(self) -> Iterator[Any]:
110+
return iter(self._body)
112111

113112
def __str__(self) -> str:
114113
return str(self._body)
@@ -134,7 +133,7 @@ def raw(self) -> _BodyType:
134133
class TextApiResponse(ApiResponse[str]):
135134
"""API responses which are text such as 'text/plain' or 'text/csv'"""
136135

137-
def __iter__(self) -> Iterable[str]:
136+
def __iter__(self) -> Iterator[str]:
138137
return iter(self.body)
139138

140139
def __getitem__(self, item: Union[int, slice]) -> str:
@@ -148,7 +147,7 @@ def body(self) -> str:
148147
class BinaryApiResponse(ApiResponse[bytes]):
149148
"""API responses which are a binary response such as Mapbox vector tiles"""
150149

151-
def __iter__(self) -> Iterable[int]:
150+
def __iter__(self) -> Iterator[int]:
152151
return iter(self.body)
153152

154153
@overload
@@ -214,7 +213,7 @@ def __getitem__(
214213
) -> Union[_ListItemBodyType, List[_ListItemBodyType]]:
215214
return self.body[item]
216215

217-
def __iter__(self) -> Iterable[_ListItemBodyType]:
216+
def __iter__(self) -> Iterator[_ListItemBodyType]:
218217
return iter(self.body)
219218

220219
@property

0 commit comments

Comments
 (0)