Skip to content

Commit 03908da

Browse files
committed
chore(code) remove Generator
1 parent fb56413 commit 03908da

18 files changed

+371
-30
lines changed

cloudfoundry_client/common_objects.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from collections.abc import Callable
2+
from collections.abc import Callable, Generator
33
from typing import TypeVar, Generic
44

55

@@ -19,7 +19,7 @@ def __init__(self, *args, **kwargs):
1919
ENTITY = TypeVar('ENTITY')
2020

2121

22-
class Pagination(Generic[ENTITY]):
22+
class Pagination(Generic[ENTITY], Generator[ENTITY, None, None]):
2323
def __init__(self, first_page: JsonObject,
2424
total_result: int,
2525
next_page_loader: Callable[[JsonObject], JsonObject | None],
@@ -37,10 +37,7 @@ def __init__(self, first_page: JsonObject,
3737
def total_results(self) -> int:
3838
return self._total_results
3939

40-
def __iter__(self):
41-
return self
42-
43-
def __next__(self) -> ENTITY:
40+
def send(self, value) -> ENTITY:
4441
try:
4542
if self._cursor is None:
4643
self._current_page = self._first_page
@@ -52,3 +49,15 @@ def __next__(self) -> ENTITY:
5249
raise
5350
self._cursor = self._resources_accessor(self._current_page).__iter__()
5451
return self._instance_creator(self._cursor.__next__())
52+
53+
def throw(self, typ, val=None, tb=None):
54+
super().throw(typ, val, tb)
55+
56+
def close(self):
57+
super().close()
58+
59+
def __iter__(self):
60+
return self
61+
62+
def __next__(self) -> ENTITY:
63+
return self.send(None)

cloudfoundry_client/doppler/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import re
3-
from typing import Generator
3+
from collections.abc import Generator
44
from urllib.parse import urlparse
55

66
from oauth2_client.credentials_manager import CredentialManager

cloudfoundry_client/networking/entities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
2-
from collections.abc import Callable
2+
from collections.abc import Callable, Generator
33
from functools import reduce
4-
from typing import Any, Generator, TYPE_CHECKING
4+
from typing import Any, TYPE_CHECKING
55
from urllib.parse import quote
66

77
from requests import Response

cloudfoundry_client/operations/push/file_helper.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import os
33
import stat
44
import zipfile
5-
from collections.abc import Callable
6-
from typing import Generator
5+
from collections.abc import Callable, Generator
76

87

98
class FileHelper(object):

cloudfoundry_client/v2/events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Generator, TYPE_CHECKING
1+
from collections.abc import Generator
2+
from typing import TYPE_CHECKING
23

34
from cloudfoundry_client.v2.entities import EntityManager, Entity
45

File renamed without changes.

tests/fixtures/fake/GET_invalid_entity_with_invalid_entity_type.json renamed to tests/fixtures/v2/fake/GET_invalid_entity_with_invalid_entity_type.json

File renamed without changes.

tests/fixtures/fake/GET_invalid_entity_with_null_entity.json renamed to tests/fixtures/v2/fake/GET_invalid_entity_with_null_entity.json

File renamed without changes.

tests/fixtures/fake/GET_invalid_entity_without_entity.json renamed to tests/fixtures/v2/fake/GET_invalid_entity_without_entity.json

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)