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

Commit

Permalink
fix: Add async context manager return types (#505)
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

* Add workaround for b/275029141

* 🦉 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>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Jul 4, 2023
1 parent ef8e474 commit a4099cc
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 148 deletions.
2 changes: 1 addition & 1 deletion google/cloud/dlp_v2/services/dlp_service/async_client.py
Expand Up @@ -4238,7 +4238,7 @@ async def sample_finish_dlp_job():
metadata=metadata,
)

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
77 changes: 26 additions & 51 deletions google/cloud/dlp_v2/types/storage.py
Expand Up @@ -94,71 +94,46 @@ class FileType(proto.Enum):
storage scan.
TEXT_FILE (2):
Included file extensions:
::
asc,asp, aspx, brf, c, cc,cfm, cgi, cpp, csv, cxx, c++, cs, css, dart,
dat, dot, eml,, epbub, ged, go, h, hh, hpp, hxx, h++, hs, html, htm,
mkd, markdown, m, ml, mli, perl, pl, plist, pm, php, phtml, pht,
properties, py, pyw, rb, rbw, rs, rss, rc, scala, sh, sql, swift, tex,
shtml, shtm, xhtml, lhs, ics, ini, java, js, json, kix, kml, ocaml, md,
txt, text, tsv, vb, vcard, vcs, wml, xcodeproj, xml, xsl, xsd, yml, yaml.
asc,asp, aspx, brf, c, cc,cfm, cgi, cpp, csv,
cxx, c++, cs, css, dart, dat, dot, eml,,
epbub, ged, go, h, hh, hpp, hxx, h++, hs, html,
htm, mkd, markdown, m, ml, mli, perl, pl,
plist, pm, php, phtml, pht, properties, py,
pyw, rb, rbw, rs, rss, rc, scala, sh, sql,
swift, tex, shtml, shtm, xhtml, lhs, ics, ini,
java, js, json, kix, kml, ocaml, md, txt,
text, tsv, vb, vcard, vcs, wml, xcodeproj, xml,
xsl, xsd, yml, yaml.
IMAGE (3):
Included file extensions:
::
bmp, gif, jpg, jpeg, jpe, png.
Included file extensions: bmp, gif, jpg, jpeg, jpe, png.
bytes_limit_per_file has no effect on image files. Image
inspection is restricted to 'global', 'us', 'asia', and
'europe'.
WORD (5):
Word files >30 MB will be scanned as binary files. Included
file extensions:
::
docx, dotx, docm, dotm
Word files >30 MB will be scanned as binary
files. Included file extensions:
docx, dotx, docm, dotm
PDF (6):
PDF files >30 MB will be scanned as binary files. Included
file extensions:
::
pdf
PDF files >30 MB will be scanned as binary
files. Included file extensions:
pdf
AVRO (7):
Included file extensions:
::
avro
avro
CSV (8):
Included file extensions:
::
csv
csv
TSV (9):
Included file extensions:
::
tsv
tsv
POWERPOINT (11):
Powerpoint files >30 MB will be scanned as binary files.
Included file extensions:
::
pptx, pptm, potx, potm, pot
Powerpoint files >30 MB will be scanned as
binary files. Included file extensions:
pptx, pptm, potx, potm, pot
EXCEL (12):
Excel files >30 MB will be scanned as binary files. Included
file extensions:
::
xlsx, xlsm, xltx, xltm
Excel files >30 MB will be scanned as binary
files. Included file extensions:
xlsx, xlsm, xltx, xltm
"""
FILE_TYPE_UNSPECIFIED = 0
BINARY_FILE = 1
Expand Down
1 change: 0 additions & 1 deletion noxfile.py
Expand Up @@ -287,7 +287,6 @@ def docs(session):
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
session.run(
"sphinx-build",
"-W", # warnings as errors
"-T", # show full traceback on exception
"-N", # no colors
"-b",
Expand Down
7 changes: 7 additions & 0 deletions owlbot.py
Expand Up @@ -51,6 +51,13 @@

python.py_samples(skip_readmes=True)

# ignore docs warnings (only fail on errors). See b/275029141
s.replace(
'noxfile.py',
'"-W", # warnings as errors',
''
)

# run format session for all directories which have a noxfile
for noxfile in Path(".").glob("**/noxfile.py"):
s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-dlp",
"version": "3.12.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
114 changes: 20 additions & 94 deletions tests/unit/gapic/dlp_v2/test_dlp_service.py
Expand Up @@ -2674,9 +2674,11 @@ async def test_list_inspect_templates_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_inspect_templates(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 @@ -4142,9 +4144,11 @@ async def test_list_deidentify_templates_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_deidentify_templates(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 @@ -4411,13 +4415,6 @@ def test_create_job_trigger(request_type, transport: str = "grpc"):
display_name="display_name_value",
description="description_value",
status=dlp.JobTrigger.Status.HEALTHY,
inspect_job=dlp.InspectJobConfig(
storage_config=storage.StorageConfig(
datastore_options=storage.DatastoreOptions(
partition_id=storage.PartitionId(project_id="project_id_value")
)
)
),
)
response = client.create_job_trigger(request)

Expand Down Expand Up @@ -4682,13 +4679,6 @@ def test_update_job_trigger(request_type, transport: str = "grpc"):
display_name="display_name_value",
description="description_value",
status=dlp.JobTrigger.Status.HEALTHY,
inspect_job=dlp.InspectJobConfig(
storage_config=storage.StorageConfig(
datastore_options=storage.DatastoreOptions(
partition_id=storage.PartitionId(project_id="project_id_value")
)
)
),
)
response = client.update_job_trigger(request)

Expand Down Expand Up @@ -5201,13 +5191,6 @@ def test_get_job_trigger(request_type, transport: str = "grpc"):
display_name="display_name_value",
description="description_value",
status=dlp.JobTrigger.Status.HEALTHY,
inspect_job=dlp.InspectJobConfig(
storage_config=storage.StorageConfig(
datastore_options=storage.DatastoreOptions(
partition_id=storage.PartitionId(project_id="project_id_value")
)
)
),
)
response = client.get_job_trigger(request)

Expand Down Expand Up @@ -5857,9 +5840,11 @@ async def test_list_job_triggers_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_job_triggers(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 @@ -6126,13 +6111,6 @@ def test_activate_job_trigger(request_type, transport: str = "grpc"):
type_=dlp.DlpJobType.INSPECT_JOB,
state=dlp.DlpJob.JobState.PENDING,
job_trigger_name="job_trigger_name_value",
risk_details=dlp.AnalyzeDataSourceRiskDetails(
requested_privacy_metric=dlp.PrivacyMetric(
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
field=storage.FieldId(name="name_value")
)
)
),
)
response = client.activate_job_trigger(request)

Expand Down Expand Up @@ -6301,13 +6279,6 @@ def test_create_dlp_job(request_type, transport: str = "grpc"):
type_=dlp.DlpJobType.INSPECT_JOB,
state=dlp.DlpJob.JobState.PENDING,
job_trigger_name="job_trigger_name_value",
risk_details=dlp.AnalyzeDataSourceRiskDetails(
requested_privacy_metric=dlp.PrivacyMetric(
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
field=storage.FieldId(name="name_value")
)
)
),
)
response = client.create_dlp_job(request)

Expand Down Expand Up @@ -7005,9 +6976,11 @@ async def test_list_dlp_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_dlp_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 @@ -7038,13 +7011,6 @@ def test_get_dlp_job(request_type, transport: str = "grpc"):
type_=dlp.DlpJobType.INSPECT_JOB,
state=dlp.DlpJob.JobState.PENDING,
job_trigger_name="job_trigger_name_value",
risk_details=dlp.AnalyzeDataSourceRiskDetails(
requested_privacy_metric=dlp.PrivacyMetric(
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
field=storage.FieldId(name="name_value")
)
)
),
)
response = client.get_dlp_job(request)

Expand Down Expand Up @@ -8810,9 +8776,11 @@ async def test_list_stored_info_types_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_stored_info_types(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 @@ -13051,13 +13019,6 @@ def test_create_job_trigger_rest(request_type):
display_name="display_name_value",
description="description_value",
status=dlp.JobTrigger.Status.HEALTHY,
inspect_job=dlp.InspectJobConfig(
storage_config=storage.StorageConfig(
datastore_options=storage.DatastoreOptions(
partition_id=storage.PartitionId(project_id="project_id_value")
)
)
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -13337,13 +13298,6 @@ def test_update_job_trigger_rest(request_type):
display_name="display_name_value",
description="description_value",
status=dlp.JobTrigger.Status.HEALTHY,
inspect_job=dlp.InspectJobConfig(
storage_config=storage.StorageConfig(
datastore_options=storage.DatastoreOptions(
partition_id=storage.PartitionId(project_id="project_id_value")
)
)
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -13885,13 +13839,6 @@ def test_get_job_trigger_rest(request_type):
display_name="display_name_value",
description="description_value",
status=dlp.JobTrigger.Status.HEALTHY,
inspect_job=dlp.InspectJobConfig(
storage_config=storage.StorageConfig(
datastore_options=storage.DatastoreOptions(
partition_id=storage.PartitionId(project_id="project_id_value")
)
)
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -14749,13 +14696,6 @@ def test_activate_job_trigger_rest(request_type):
type_=dlp.DlpJobType.INSPECT_JOB,
state=dlp.DlpJob.JobState.PENDING,
job_trigger_name="job_trigger_name_value",
risk_details=dlp.AnalyzeDataSourceRiskDetails(
requested_privacy_metric=dlp.PrivacyMetric(
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
field=storage.FieldId(name="name_value")
)
)
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -14971,13 +14911,6 @@ def test_create_dlp_job_rest(request_type):
type_=dlp.DlpJobType.INSPECT_JOB,
state=dlp.DlpJob.JobState.PENDING,
job_trigger_name="job_trigger_name_value",
risk_details=dlp.AnalyzeDataSourceRiskDetails(
requested_privacy_metric=dlp.PrivacyMetric(
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
field=storage.FieldId(name="name_value")
)
)
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -15599,13 +15532,6 @@ def test_get_dlp_job_rest(request_type):
type_=dlp.DlpJobType.INSPECT_JOB,
state=dlp.DlpJob.JobState.PENDING,
job_trigger_name="job_trigger_name_value",
risk_details=dlp.AnalyzeDataSourceRiskDetails(
requested_privacy_metric=dlp.PrivacyMetric(
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
field=storage.FieldId(name="name_value")
)
)
),
)

# Wrap the value into a proper Response obj
Expand Down

0 comments on commit a4099cc

Please sign in to comment.