Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
fix: Add async context manager return types (#340)
Browse files Browse the repository at this point in the history
* fix: Add async context manager return types

chore: Mock return_value should not populate oneof message fields

chore: Support snippet generation for services that only support REST transport

chore: Update gapic-generator-python to v1.11.0
PiperOrigin-RevId: 545430278

Source-Link: googleapis/googleapis@601b532

Source-Link: googleapis/googleapis-gen@b3f18d0
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjNmMThkMGY2NTYwYTg1NTAyMmZkMDU4ODY1ZTc2MjA0NzlkN2FmOSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Jul 4, 2023
1 parent f52edbc commit 7e65978
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ async def list_locations(
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "CloudSchedulerAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ async def list_locations(
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "CloudSchedulerAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-scheduler",
"version": "2.11.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-scheduler",
"version": "2.11.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
18 changes: 4 additions & 14 deletions tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,11 @@ async def test_list_jobs_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_jobs(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1157,7 +1159,6 @@ def test_get_job(request_type, transport: str = "grpc"):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.get_job(request)

Expand Down Expand Up @@ -1402,7 +1403,6 @@ def test_create_job(request_type, transport: str = "grpc"):
schedule="schedule_value",
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.create_job(request)

Expand Down Expand Up @@ -1657,7 +1657,6 @@ def test_update_job(request_type, transport: str = "grpc"):
schedule="schedule_value",
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.update_job(request)

Expand Down Expand Up @@ -2132,7 +2131,6 @@ def test_pause_job(request_type, transport: str = "grpc"):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.pause_job(request)

Expand Down Expand Up @@ -2377,7 +2375,6 @@ def test_resume_job(request_type, transport: str = "grpc"):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.resume_job(request)

Expand Down Expand Up @@ -2622,7 +2619,6 @@ def test_run_job(request_type, transport: str = "grpc"):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.run_job(request)

Expand Down Expand Up @@ -3200,7 +3196,6 @@ def test_get_job_rest(request_type):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3529,7 +3524,6 @@ def test_create_job_rest(request_type):
schedule="schedule_value",
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3930,7 +3924,6 @@ def test_update_job_rest(request_type):
schedule="schedule_value",
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -4513,7 +4506,6 @@ def test_pause_job_rest(request_type):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -4784,7 +4776,6 @@ def test_resume_job_rest(request_type):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -5058,7 +5049,6 @@ def test_run_job_rest(request_type):
schedule="schedule_value",
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down
18 changes: 4 additions & 14 deletions tests/unit/gapic/scheduler_v1beta1/test_cloud_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,11 @@ async def test_list_jobs_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_jobs(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1158,7 +1160,6 @@ def test_get_job(request_type, transport: str = "grpc"):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.get_job(request)

Expand Down Expand Up @@ -1407,7 +1408,6 @@ def test_create_job(request_type, transport: str = "grpc"):
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.create_job(request)

Expand Down Expand Up @@ -1666,7 +1666,6 @@ def test_update_job(request_type, transport: str = "grpc"):
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.update_job(request)

Expand Down Expand Up @@ -2145,7 +2144,6 @@ def test_pause_job(request_type, transport: str = "grpc"):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.pause_job(request)

Expand Down Expand Up @@ -2394,7 +2392,6 @@ def test_resume_job(request_type, transport: str = "grpc"):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.resume_job(request)

Expand Down Expand Up @@ -2643,7 +2640,6 @@ def test_run_job(request_type, transport: str = "grpc"):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)
response = client.run_job(request)

Expand Down Expand Up @@ -3229,7 +3225,6 @@ def test_get_job_rest(request_type):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3561,7 +3556,6 @@ def test_create_job_rest(request_type):
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3966,7 +3960,6 @@ def test_update_job_rest(request_type):
time_zone="time_zone_value",
state=gcs_job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -4555,7 +4548,6 @@ def test_pause_job_rest(request_type):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -4829,7 +4821,6 @@ def test_resume_job_rest(request_type):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -5105,7 +5096,6 @@ def test_run_job_rest(request_type):
time_zone="time_zone_value",
state=job.Job.State.ENABLED,
legacy_app_engine_cron=True,
pubsub_target=target.PubsubTarget(topic_name="topic_name_value"),
)

# Wrap the value into a proper Response obj
Expand Down

0 comments on commit 7e65978

Please sign in to comment.