Skip to content

Commit

Permalink
style: apply Python 3.13 linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed Dec 9, 2024
1 parent 8b1aa12 commit 185a431
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions gcp_pilot/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def list_apis(
self,
project_id: str | None = None,
location: str | None = "global",
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._location_path(project_id=project_id, location=location),
)
Expand Down Expand Up @@ -94,7 +94,7 @@ def list_configs(
self,
api_name: str,
project_id: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._api_path(api_name=api_name, project_id=project_id),
)
Expand Down Expand Up @@ -164,7 +164,7 @@ def list_gateways(
self,
project_id: str | None = None,
location: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._location_path(project_id=project_id, location=location),
)
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def undelete(self, key_id: str, project_id: str | None = None):
name=self._key_path(key_id=key_id, project_id=project_id),
)

def list(self, project_id: str | None = None) -> Generator[Key, None, None]:
def list(self, project_id: str | None = None) -> Generator[Key]:
params = dict(parent=self._location_path(project_id=project_id))
data = self._paginate(
method=self.client.projects().locations().keys().list,
Expand Down
4 changes: 2 additions & 2 deletions gcp_pilot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def _list(
method: Callable,
result_key: str = "items",
params: dict[str, Any] | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
results = self._execute(
method=method,
**params,
Expand All @@ -438,7 +438,7 @@ def _paginate(
params: dict[str, Any] | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
page_token = None
params = params or {}

Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def get_builds(
trigger_id: str | None = None,
project_id: str | None = None,
status: str | None = None,
) -> Generator[cloudbuild_v1.Build, None, None]:
) -> Generator[cloudbuild_v1.Build]:
# https://cloud.google.com/cloud-build/docs/view-build-results#filtering_build_results_using_queries
filters = []
if trigger_id:
Expand Down
6 changes: 3 additions & 3 deletions gcp_pilot/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _date_to_str(self, dt: datetime.date, fmt="%Y-%m-%dT%H:%M:%SZ"):

return dt.strftime(fmt)

def get_calendars(self) -> Generator[ResourceType, None, None]:
def get_calendars(self) -> Generator[ResourceType]:
params = {}
yield from self._paginate(
method=self.client.calendarList().list,
Expand Down Expand Up @@ -249,7 +249,7 @@ def get_events(
calendar_id: str = "primary",
starts_at: datetime.date | None = None,
ends_at: datetime.date | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
min_date = self._date_to_str(starts_at) if starts_at else None
max_date = self._date_to_str(ends_at) if ends_at else None

Expand Down Expand Up @@ -283,7 +283,7 @@ def delete_event(self, event_id: str, calendar_id: str = "primary") -> ResourceT
eventId=event_id,
)

def get_recurrent_events(self, event_id: str, calendar_id: str = "primary") -> Generator[ResourceType, None, None]:
def get_recurrent_events(self, event_id: str, calendar_id: str = "primary") -> Generator[ResourceType]:
page_size = 100
params = dict(
calendarId=calendar_id,
Expand Down
4 changes: 2 additions & 2 deletions gcp_pilot/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def get_room(self, room_id: str) -> ResourceType:
name=self._room_path(room_id=room_id),
)

def get_rooms(self) -> Generator[ResourceType, None, None]:
def get_rooms(self) -> Generator[ResourceType]:
yield from self._paginate(
method=self.client.spaces().list,
result_key="spaces",
Expand All @@ -287,7 +287,7 @@ def get_member(self, room_id: str, member_id: str) -> ResourceType:
name=name,
)

def get_members(self, room_id: str) -> Generator[ResourceType, None, None]:
def get_members(self, room_id: str) -> Generator[ResourceType]:
yield from self._paginate(
method=self.client.spaces().members().list,
result_key="memberships",
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def query(
yield item
found.add(item.id)

def filter(self, **kwargs) -> Generator[Document, None, None]:
def filter(self, **kwargs) -> Generator[Document]:
for entity in self.query(**kwargs):
yield self.doc_klass.from_entity(entity=entity)

Expand Down
4 changes: 2 additions & 2 deletions gcp_pilot/datastream.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_streams(
self,
location: str | None = None,
project_id: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
location_path = self._location_path(location=location, project_id=project_id)
params = {"parent": location_path}
yield from self._paginate(
Expand Down Expand Up @@ -58,7 +58,7 @@ def get_objects(
stream_name: str,
location: str | None = None,
project_id: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
stream_path = self._stream_path(stream_name=stream_name, location=location, project_id=project_id)
params = {"parent": stream_path}
yield from self._paginate(
Expand Down
6 changes: 3 additions & 3 deletions gcp_pilot/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _build_context(self, customer: str | None = None, domain: str | None = None)
context["domain"] = domain
return context

def get_groups(self, customer: str | None = None, domain: str | None = None) -> Generator[GroupType, None, None]:
def get_groups(self, customer: str | None = None, domain: str | None = None) -> Generator[GroupType]:
params = self._build_context(customer=customer, domain=domain)
yield from self._paginate(
method=self.client.groups().list,
Expand Down Expand Up @@ -79,7 +79,7 @@ def delete_group(self, group_id: str) -> GroupType:
groupKey=group_id,
)

def get_group_members(self, group_id: str) -> Generator[MemberType, None, None]:
def get_group_members(self, group_id: str) -> Generator[MemberType]:
params = dict(
groupKey=group_id,
)
Expand All @@ -106,7 +106,7 @@ def delete_group_member(self, group_id: str, member_id: str) -> MemberType:
memberKey=member_id,
)

def get_users(self, customer: str | None = None, domain: str | None = None) -> Generator[UserType, None, None]:
def get_users(self, customer: str | None = None, domain: str | None = None) -> Generator[UserType]:
params = self._build_context(customer=customer, domain=domain)
yield from self._paginate(
method=self.client.users().list,
Expand Down
4 changes: 2 additions & 2 deletions gcp_pilot/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _get_client_extra_kwargs(self):
"project": self.project_id,
}

def list_zones(self) -> Generator[dns.ManagedZone, None, None]:
def list_zones(self) -> Generator[dns.ManagedZone]:
yield from self.client.list_zones()

def _build_zone(self, name: str, dns_name: str, description: str | None = None) -> dns.ManagedZone:
Expand Down Expand Up @@ -70,7 +70,7 @@ def delete_zone(self, name: str, dns_name: str, exists_ok: bool = True) -> None:
raise exceptions.NotFound()
return zone.delete()

def list_records(self, zone_name: str, zone_dns: str) -> Generator[dns.ResourceRecordSet, None, None]:
def list_records(self, zone_name: str, zone_dns: str) -> Generator[dns.ResourceRecordSet]:
zone = self._build_zone(name=zone_name, dns_name=zone_dns)

yield from zone.list_resource_record_sets() # TODO Why paging does not work like docs?
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_functions(
self,
project_id: str | None = None,
location: str | None = None,
) -> Generator[FunctionType, None, None]:
) -> Generator[FunctionType]:
params = dict(
parent=self._parent_path(project_id=project_id, location=location),
)
Expand Down
8 changes: 4 additions & 4 deletions gcp_pilot/healthcare.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def list_datasets(
self,
project_id: str | None = None,
location: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._location_path(project_id=project_id, location=location),
)
Expand Down Expand Up @@ -156,7 +156,7 @@ def _request(self):
request.raise_for_status()
self.response = request.json()

def __iter__(self) -> Generator[dict, None, None]:
def __iter__(self) -> Generator[dict]:
while True:
yield from self.get_page_resources()
self.cursor = self.next_cursor
Expand All @@ -170,7 +170,7 @@ def first(self) -> dict:
except StopIteration as exc:
raise exceptions.NotFound() from exc

def get_page_resources(self) -> Generator[DomainResource, None, None]:
def get_page_resources(self) -> Generator[DomainResource]:
if self.total == 0:
return

Expand Down Expand Up @@ -257,7 +257,7 @@ def list_stores(
dataset_name: str,
project_id: str | None = None,
location: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._dataset_path(name=dataset_name, project_id=project_id, location=location),
)
Expand Down
4 changes: 2 additions & 2 deletions gcp_pilot/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_service_account(
service_account = self.get_service_account(name=name, project_id=project_id)
return service_account

def list_service_accounts(self, project_id: str | None = None) -> Generator[AccountType, None, None]:
def list_service_accounts(self, project_id: str | None = None) -> Generator[AccountType]:
params = dict(
name=self._project_path(project_id=project_id),
)
Expand Down Expand Up @@ -162,7 +162,7 @@ def create_key(
)
return self._format_key(data=account_key)

def list_keys(self, service_account_name: str, project_id: str | None = None) -> Generator[KeyType, None, None]:
def list_keys(self, service_account_name: str, project_id: str | None = None) -> Generator[KeyType]:
parent = self._service_account_path(
email=self._build_service_account_email(name=service_account_name, project_id=project_id),
project_id=project_id,
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _service_path(self, service_id: str, project_id: str | None = None) -> str:
parent = self._project_path(project_id=project_id)
return f"{parent}/services/{service_id}"

def list_services(self, project_id: str | None = None) -> Generator[ResourceType, None, None]:
def list_services(self, project_id: str | None = None) -> Generator[ResourceType]:
parent = self._project_path(project_id=project_id)

params = dict(
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/people.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, email: str, **kwargs):
def _get_project_default_location(self, project_id: str | None = None) -> str | None:
return None

def get_people(self, query: str | None = None, fields: list[str] | None = None) -> Generator[UserType, None, None]:
def get_people(self, query: str | None = None, fields: list[str] | None = None) -> Generator[UserType]:
params = {
"readMask": ",".join(fields or USER_FIELDS),
"sources": ["DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE", "DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT"],
Expand Down
4 changes: 2 additions & 2 deletions gcp_pilot/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def list_topics(
prefix: str = "",
suffix: str = "",
project_id: str | None = None,
) -> Generator[Topic, None, None]:
) -> Generator[Topic]:
project_path = self._project_path(project_id=project_id)
topics = self.client.list_topics(
project=project_path,
Expand Down Expand Up @@ -143,7 +143,7 @@ def list_subscriptions(
prefix: str = "",
suffix: str = "",
project_id: str | None = None,
) -> Generator[Subscription, None, None]:
) -> Generator[Subscription]:
all_subscriptions = self.client.list_subscriptions(
project=f"projects/{project_id or self.project_id}",
)
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class ServiceAgent:
_suffixes = ["Service Agent", "Agent", "Service Account"]

@classmethod
def get_available_agents(cls) -> Generator[str, None, None]:
def get_available_agents(cls) -> Generator[str]:
for agent in cls.agents:
name = agent
for suffix in cls._suffixes:
Expand Down
8 changes: 4 additions & 4 deletions gcp_pilot/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _domain_mapping_path(self, domain: str, project_id: str | None = None):
parent = self._namespace_path(project_id=project_id)
return f"{parent}/domainmappings/{domain}"

def list_services(self, project_id: str | None = None) -> Generator[ResourceType, None, None]:
def list_services(self, project_id: str | None = None) -> Generator[ResourceType]:
params = dict(
parent=self._namespace_path(project_id=project_id),
)
Expand Down Expand Up @@ -108,7 +108,7 @@ def create_service(
body=body,
)

def list_locations(self, project_id: str | None = None) -> Generator[ResourceType, None, None]:
def list_locations(self, project_id: str | None = None) -> Generator[ResourceType]:
params = dict(
name=self._project_path(project_id=project_id),
)
Expand All @@ -122,7 +122,7 @@ def list_revisions(
self,
service_name: str | None = None,
project_id: str | None = None,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._namespace_path(project_id=project_id),
)
Expand All @@ -135,7 +135,7 @@ def list_revisions(
if not service_name or item["metadata"]["labels"]["serving.knative.dev/service"] == service_name:
yield item

def list_domain_mappings(self, project_id: str | None = None) -> Generator[ResourceType, None, None]:
def list_domain_mappings(self, project_id: str | None = None) -> Generator[ResourceType]:
params = dict(
parent=self._namespace_path(project_id=project_id),
)
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def update(
)
return response

def list(self, prefix: str = "", project_id: str | None = None) -> Generator[scheduler.Job, None, None]:
def list(self, prefix: str = "", project_id: str | None = None) -> Generator[scheduler.Job]:
parent = self._parent_path(project_id=project_id)
for job in self.client.list_jobs(parent=parent):
if job.name.split("/jobs/")[-1].startswith(prefix):
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/service_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def list_services(
self,
project_id: str | None = None,
status: ServiceStatus = ServiceStatus.ENABLED,
) -> Generator[ResourceType, None, None]:
) -> Generator[ResourceType]:
params = dict(
parent=self._project_path(project_id=project_id),
)
Expand Down
6 changes: 3 additions & 3 deletions gcp_pilot/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, **kwargs):
**kwargs,
)

def list_instances(self, project_id: str | None = None) -> Generator[InstanceType, None, None]:
def list_instances(self, project_id: str | None = None) -> Generator[InstanceType]:
params = dict(project=project_id or self.project_id)
instances = self._paginate(
method=self.client.instances().list,
Expand Down Expand Up @@ -131,7 +131,7 @@ def create_database(
return self.get_database(instance=instance, database=name, project_id=project_id)
raise

def list_users(self, instance: str, project_id: str | None = None) -> Generator[UserType, None, None]:
def list_users(self, instance: str, project_id: str | None = None) -> Generator[UserType]:
params = dict(
instance=instance,
project=project_id or self.project_id,
Expand Down Expand Up @@ -170,7 +170,7 @@ def create_ssl_cert(
body=body,
)

def list_ssl_certs(self, instance: str, project_id: str | None = None) -> Generator[dict, None, None]:
def list_ssl_certs(self, instance: str, project_id: str | None = None) -> Generator[dict]:
params = dict(
instance=instance,
project=project_id or self.project_id,
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def delete(self, file_name: str, bucket_name: str | None = None) -> None:
blob = bucket.blob(file_name)
return blob.delete()

def list_files(self, bucket_name: str, prefix: str | None = None) -> Generator[Blob, None, None]:
def list_files(self, bucket_name: str, prefix: str | None = None) -> Generator[Blob]:
blobs = self.client.list_blobs(
bucket_name,
prefix=prefix,
Expand Down
2 changes: 1 addition & 1 deletion gcp_pilot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def delete_task(
if not not_found_ok:
raise

def list_tasks(self, queue_name: str, project_id: str | None = None) -> Generator[tasks_v2.Task, None, None]:
def list_tasks(self, queue_name: str, project_id: str | None = None) -> Generator[tasks_v2.Task]:
queue_path = self._queue_path(queue=queue_name, project_id=project_id)
request = tasks_v2.ListTasksRequest(
parent=queue_path,
Expand Down

0 comments on commit 185a431

Please sign in to comment.