Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 8.11] Fix __iter__ return type to Iterator #130

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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