Skip to content

Commit

Permalink
fix: Add async context manager return types (#11448)
Browse files Browse the repository at this point in the history
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
3 people authored Jul 4, 2023
1 parent 3885820 commit 4d2c35a
Show file tree
Hide file tree
Showing 842 changed files with 91,846 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -6158,7 +6158,7 @@ async def list_locations(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6870,7 +6870,7 @@ def __call__(
request_kwargs = json_format.MessageToDict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)

body = json.loads(json.dumps(transcoded_request["body"]))
body = json.dumps(transcoded_request["body"])
uri = transcoded_request["uri"]
method = transcoded_request["method"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5467,7 +5467,7 @@ class Aggregation(proto.Message):
Count the number of matching objects.
This field is a member of `oneof`_ ``aggregation_function``.
sum_ (google.cloud.migrationcenter_v1.types.Aggregation.Sum):
sum (google.cloud.migrationcenter_v1.types.Aggregation.Sum):
Sum over a numeric field.
This field is a member of `oneof`_ ``aggregation_function``.
Expand Down Expand Up @@ -5521,7 +5521,7 @@ class Frequency(proto.Message):
oneof="aggregation_function",
message=Count,
)
sum_: Sum = proto.Field(
sum: Sum = proto.Field(
proto.MESSAGE,
number=3,
oneof="aggregation_function",
Expand Down Expand Up @@ -5557,7 +5557,7 @@ class AggregationResult(proto.Message):
count (google.cloud.migrationcenter_v1.types.AggregationResult.Count):
This field is a member of `oneof`_ ``result``.
sum_ (google.cloud.migrationcenter_v1.types.AggregationResult.Sum):
sum (google.cloud.migrationcenter_v1.types.AggregationResult.Sum):
This field is a member of `oneof`_ ``result``.
histogram (google.cloud.migrationcenter_v1.types.AggregationResult.Histogram):
Expand Down Expand Up @@ -5666,7 +5666,7 @@ class Frequency(proto.Message):
oneof="result",
message=Count,
)
sum_: Sum = proto.Field(
sum: Sum = proto.Field(
proto.MESSAGE,
number=3,
oneof="result",
Expand Down
3 changes: 1 addition & 2 deletions packages/google-cloud-migrationcenter/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,9 @@ def docfx(session):

session.install("-e", ".")
session.install(
"sphinx==4.0.1",
"gcp-sphinx-docfx-yaml",
"alabaster",
"recommonmark",
"gcp-sphinx-docfx-yaml",
)

shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,9 +1158,11 @@ async def test_list_assets_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_assets(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 @@ -1190,7 +1192,6 @@ def test_get_asset(request_type, transport: str = "grpc"):
name="name_value",
sources=["sources_value"],
assigned_groups=["assigned_groups_value"],
machine_details=migrationcenter.MachineDetails(uuid="uuid_value"),
)
response = client.get_asset(request)

Expand Down Expand Up @@ -1431,7 +1432,6 @@ def test_update_asset(request_type, transport: str = "grpc"):
name="name_value",
sources=["sources_value"],
assigned_groups=["assigned_groups_value"],
machine_details=migrationcenter.MachineDetails(uuid="uuid_value"),
)
response = client.update_asset(request)

Expand Down Expand Up @@ -3384,9 +3384,11 @@ async def test_list_import_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_import_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 @@ -3417,11 +3419,6 @@ def test_get_import_job(request_type, transport: str = "grpc"):
display_name="display_name_value",
state=migrationcenter.ImportJob.ImportJobState.IMPORT_JOB_STATE_PENDING,
asset_source="asset_source_value",
validation_report=migrationcenter.ValidationReport(
file_validations=[
migrationcenter.FileValidationReport(file_name="file_name_value")
]
),
)
response = client.get_import_job(request)

Expand Down Expand Up @@ -4631,9 +4628,6 @@ def test_get_import_data_file(request_type, transport: str = "grpc"):
display_name="display_name_value",
format_=migrationcenter.ImportJobFormat.IMPORT_JOB_FORMAT_RVTOOLS_XLSX,
state=migrationcenter.ImportDataFile.State.CREATING,
upload_file_info=migrationcenter.UploadFileInfo(
signed_uri="signed_uri_value"
),
)
response = client.get_import_data_file(request)

Expand Down Expand Up @@ -5311,9 +5305,11 @@ async def test_list_import_data_files_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_import_data_files(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 @@ -6237,9 +6233,11 @@ async def test_list_groups_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_groups(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 @@ -8113,9 +8111,11 @@ async def test_list_error_frames_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_error_frames(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 @@ -8769,9 +8769,11 @@ async def test_list_sources_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_sources(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 @@ -10188,9 +10190,11 @@ async def test_list_preference_sets_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_preference_sets(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 @@ -12630,9 +12634,11 @@ async def test_list_report_configs_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_report_configs(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 @@ -13789,9 +13795,11 @@ async def test_list_reports_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_reports(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 @@ -14394,7 +14402,6 @@ def test_get_asset_rest(request_type):
name="name_value",
sources=["sources_value"],
assigned_groups=["assigned_groups_value"],
machine_details=migrationcenter.MachineDetails(uuid="uuid_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -14925,7 +14932,6 @@ def test_update_asset_rest(request_type):
name="name_value",
sources=["sources_value"],
assigned_groups=["assigned_groups_value"],
machine_details=migrationcenter.MachineDetails(uuid="uuid_value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -17915,11 +17921,6 @@ def test_get_import_job_rest(request_type):
display_name="display_name_value",
state=migrationcenter.ImportJob.ImportJobState.IMPORT_JOB_STATE_PENDING,
asset_source="asset_source_value",
validation_report=migrationcenter.ValidationReport(
file_validations=[
migrationcenter.FileValidationReport(file_name="file_name_value")
]
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -19372,9 +19373,6 @@ def test_get_import_data_file_rest(request_type):
display_name="display_name_value",
format_=migrationcenter.ImportJobFormat.IMPORT_JOB_FORMAT_RVTOOLS_XLSX,
state=migrationcenter.ImportDataFile.State.CREATING,
upload_file_info=migrationcenter.UploadFileInfo(
signed_uri="signed_uri_value"
),
)

# Wrap the value into a proper Response obj
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.4.2" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.4.2" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ async def sample_delete_monitored_project():
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
3 changes: 1 addition & 2 deletions packages/google-cloud-monitoring-metrics-scopes/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,9 @@ def docfx(session):

session.install("-e", ".")
session.install(
"sphinx==4.0.1",
"gcp-sphinx-docfx-yaml",
"alabaster",
"recommonmark",
"gcp-sphinx-docfx-yaml",
)

shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generated code. DO NOT EDIT!
#
# Snippet for CreateMonitoredProject
# NOTE: This snippet has been automatically generated for illustrative purposes only.
# It may require modifications to work in your environment.

# To install the latest published package dependency, execute the following:
# python3 -m pip install google-cloud-monitoring-metrics-scopes


# [START monitoring_v1_generated_MetricsScopes_CreateMonitoredProject_async]
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import monitoring_metrics_scope_v1


async def sample_create_monitored_project():
# Create a client
client = monitoring_metrics_scope_v1.MetricsScopesAsyncClient()

# Initialize request argument(s)
request = monitoring_metrics_scope_v1.CreateMonitoredProjectRequest(
parent="parent_value",
)

# Make the request
operation = client.create_monitored_project(request=request)

print("Waiting for operation to complete...")

response = (await operation).result()

# Handle the response
print(response)

# [END monitoring_v1_generated_MetricsScopes_CreateMonitoredProject_async]
Loading

0 comments on commit 4d2c35a

Please sign in to comment.