Skip to content

Commit

Permalink
Fix __iter__ return type to Iterator (#129)
Browse files Browse the repository at this point in the history
Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
(cherry picked from commit 6baac50)
  • Loading branch information
altescy authored and github-actions[bot] committed Dec 13, 2023
1 parent 22dbb3d commit 5056504
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions elastic_transport/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Any,
Dict,
Generic,
Iterable,
Iterator,
List,
NoReturn,
Expand Down Expand Up @@ -107,8 +106,8 @@ def __setstate__(self, state: Tuple[_BodyType, ApiResponseMeta]) -> None:
def __len__(self) -> int:
return len(self._body)

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

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

def __iter__(self) -> Iterable[str]:
def __iter__(self) -> Iterator[str]:
return iter(self.body)

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

def __iter__(self) -> Iterable[int]:
def __iter__(self) -> Iterator[int]:
return iter(self.body)

@overload
Expand Down Expand Up @@ -214,7 +213,7 @@ def __getitem__(
) -> Union[_ListItemBodyType, List[_ListItemBodyType]]:
return self.body[item]

def __iter__(self) -> Iterable[_ListItemBodyType]:
def __iter__(self) -> Iterator[_ListItemBodyType]:
return iter(self.body)

@property
Expand Down

0 comments on commit 5056504

Please sign in to comment.