Skip to content

Commit ffadc83

Browse files
fix: Add async context manager return types (googleapis#505)
* 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: https://github.com/googleapis/googleapis-gen/commit/b3f18d0f6560a855022fd058865e7620479d7af9 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>
1 parent 69a1e52 commit ffadc83

File tree

6 files changed

+55
-148
lines changed

6 files changed

+55
-148
lines changed

packages/google-cloud-dlp/google/cloud/dlp_v2/services/dlp_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4238,7 +4238,7 @@ async def sample_finish_dlp_job():
42384238
metadata=metadata,
42394239
)
42404240

4241-
async def __aenter__(self):
4241+
async def __aenter__(self) -> "DlpServiceAsyncClient":
42424242
return self
42434243

42444244
async def __aexit__(self, exc_type, exc, tb):

packages/google-cloud-dlp/google/cloud/dlp_v2/types/storage.py

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -94,71 +94,46 @@ class FileType(proto.Enum):
9494
storage scan.
9595
TEXT_FILE (2):
9696
Included file extensions:
97-
98-
::
99-
100-
asc,asp, aspx, brf, c, cc,cfm, cgi, cpp, csv, cxx, c++, cs, css, dart,
101-
dat, dot, eml,, epbub, ged, go, h, hh, hpp, hxx, h++, hs, html, htm,
102-
mkd, markdown, m, ml, mli, perl, pl, plist, pm, php, phtml, pht,
103-
properties, py, pyw, rb, rbw, rs, rss, rc, scala, sh, sql, swift, tex,
104-
shtml, shtm, xhtml, lhs, ics, ini, java, js, json, kix, kml, ocaml, md,
105-
txt, text, tsv, vb, vcard, vcs, wml, xcodeproj, xml, xsl, xsd, yml, yaml.
97+
asc,asp, aspx, brf, c, cc,cfm, cgi, cpp, csv,
98+
cxx, c++, cs, css, dart, dat, dot, eml,,
99+
epbub, ged, go, h, hh, hpp, hxx, h++, hs, html,
100+
htm, mkd, markdown, m, ml, mli, perl, pl,
101+
plist, pm, php, phtml, pht, properties, py,
102+
pyw, rb, rbw, rs, rss, rc, scala, sh, sql,
103+
swift, tex, shtml, shtm, xhtml, lhs, ics, ini,
104+
java, js, json, kix, kml, ocaml, md, txt,
105+
text, tsv, vb, vcard, vcs, wml, xcodeproj, xml,
106+
xsl, xsd, yml, yaml.
106107
IMAGE (3):
107-
Included file extensions:
108-
109-
::
110-
111-
bmp, gif, jpg, jpeg, jpe, png.
112-
108+
Included file extensions: bmp, gif, jpg, jpeg, jpe, png.
113109
bytes_limit_per_file has no effect on image files. Image
114110
inspection is restricted to 'global', 'us', 'asia', and
115111
'europe'.
116112
WORD (5):
117-
Word files >30 MB will be scanned as binary files. Included
118-
file extensions:
119-
120-
::
121-
122-
docx, dotx, docm, dotm
113+
Word files >30 MB will be scanned as binary
114+
files. Included file extensions:
115+
docx, dotx, docm, dotm
123116
PDF (6):
124-
PDF files >30 MB will be scanned as binary files. Included
125-
file extensions:
126-
127-
::
128-
129-
pdf
117+
PDF files >30 MB will be scanned as binary
118+
files. Included file extensions:
119+
pdf
130120
AVRO (7):
131121
Included file extensions:
132-
133-
::
134-
135-
avro
122+
avro
136123
CSV (8):
137124
Included file extensions:
138-
139-
::
140-
141-
csv
125+
csv
142126
TSV (9):
143127
Included file extensions:
144-
145-
::
146-
147-
tsv
128+
tsv
148129
POWERPOINT (11):
149-
Powerpoint files >30 MB will be scanned as binary files.
150-
Included file extensions:
151-
152-
::
153-
154-
pptx, pptm, potx, potm, pot
130+
Powerpoint files >30 MB will be scanned as
131+
binary files. Included file extensions:
132+
pptx, pptm, potx, potm, pot
155133
EXCEL (12):
156-
Excel files >30 MB will be scanned as binary files. Included
157-
file extensions:
158-
159-
::
160-
161-
xlsx, xlsm, xltx, xltm
134+
Excel files >30 MB will be scanned as binary
135+
files. Included file extensions:
136+
xlsx, xlsm, xltx, xltm
162137
"""
163138
FILE_TYPE_UNSPECIFIED = 0
164139
BINARY_FILE = 1

packages/google-cloud-dlp/noxfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ def docs(session):
287287
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
288288
session.run(
289289
"sphinx-build",
290-
"-W", # warnings as errors
291290
"-T", # show full traceback on exception
292291
"-N", # no colors
293292
"-b",

packages/google-cloud-dlp/owlbot.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151

5252
python.py_samples(skip_readmes=True)
5353

54+
# ignore docs warnings (only fail on errors). See b/275029141
55+
s.replace(
56+
'noxfile.py',
57+
'"-W", # warnings as errors',
58+
''
59+
)
60+
5461
# run format session for all directories which have a noxfile
5562
for noxfile in Path(".").glob("**/noxfile.py"):
5663
s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)

packages/google-cloud-dlp/samples/generated_samples/snippet_metadata_google.privacy.dlp.v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-dlp",
11-
"version": "3.12.1"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-dlp/tests/unit/gapic/dlp_v2/test_dlp_service.py

Lines changed: 20 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,9 +2674,11 @@ async def test_list_inspect_templates_async_pages():
26742674
RuntimeError,
26752675
)
26762676
pages = []
2677-
async for page_ in (
2677+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
2678+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
2679+
async for page_ in ( # pragma: no branch
26782680
await client.list_inspect_templates(request={})
2679-
).pages: # pragma: no branch
2681+
).pages:
26802682
pages.append(page_)
26812683
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
26822684
assert page_.raw_page.next_page_token == token
@@ -4142,9 +4144,11 @@ async def test_list_deidentify_templates_async_pages():
41424144
RuntimeError,
41434145
)
41444146
pages = []
4145-
async for page_ in (
4147+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
4148+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
4149+
async for page_ in ( # pragma: no branch
41464150
await client.list_deidentify_templates(request={})
4147-
).pages: # pragma: no branch
4151+
).pages:
41484152
pages.append(page_)
41494153
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
41504154
assert page_.raw_page.next_page_token == token
@@ -4411,13 +4415,6 @@ def test_create_job_trigger(request_type, transport: str = "grpc"):
44114415
display_name="display_name_value",
44124416
description="description_value",
44134417
status=dlp.JobTrigger.Status.HEALTHY,
4414-
inspect_job=dlp.InspectJobConfig(
4415-
storage_config=storage.StorageConfig(
4416-
datastore_options=storage.DatastoreOptions(
4417-
partition_id=storage.PartitionId(project_id="project_id_value")
4418-
)
4419-
)
4420-
),
44214418
)
44224419
response = client.create_job_trigger(request)
44234420

@@ -4682,13 +4679,6 @@ def test_update_job_trigger(request_type, transport: str = "grpc"):
46824679
display_name="display_name_value",
46834680
description="description_value",
46844681
status=dlp.JobTrigger.Status.HEALTHY,
4685-
inspect_job=dlp.InspectJobConfig(
4686-
storage_config=storage.StorageConfig(
4687-
datastore_options=storage.DatastoreOptions(
4688-
partition_id=storage.PartitionId(project_id="project_id_value")
4689-
)
4690-
)
4691-
),
46924682
)
46934683
response = client.update_job_trigger(request)
46944684

@@ -5201,13 +5191,6 @@ def test_get_job_trigger(request_type, transport: str = "grpc"):
52015191
display_name="display_name_value",
52025192
description="description_value",
52035193
status=dlp.JobTrigger.Status.HEALTHY,
5204-
inspect_job=dlp.InspectJobConfig(
5205-
storage_config=storage.StorageConfig(
5206-
datastore_options=storage.DatastoreOptions(
5207-
partition_id=storage.PartitionId(project_id="project_id_value")
5208-
)
5209-
)
5210-
),
52115194
)
52125195
response = client.get_job_trigger(request)
52135196

@@ -5857,9 +5840,11 @@ async def test_list_job_triggers_async_pages():
58575840
RuntimeError,
58585841
)
58595842
pages = []
5860-
async for page_ in (
5843+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
5844+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
5845+
async for page_ in ( # pragma: no branch
58615846
await client.list_job_triggers(request={})
5862-
).pages: # pragma: no branch
5847+
).pages:
58635848
pages.append(page_)
58645849
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
58655850
assert page_.raw_page.next_page_token == token
@@ -6126,13 +6111,6 @@ def test_activate_job_trigger(request_type, transport: str = "grpc"):
61266111
type_=dlp.DlpJobType.INSPECT_JOB,
61276112
state=dlp.DlpJob.JobState.PENDING,
61286113
job_trigger_name="job_trigger_name_value",
6129-
risk_details=dlp.AnalyzeDataSourceRiskDetails(
6130-
requested_privacy_metric=dlp.PrivacyMetric(
6131-
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
6132-
field=storage.FieldId(name="name_value")
6133-
)
6134-
)
6135-
),
61366114
)
61376115
response = client.activate_job_trigger(request)
61386116

@@ -6301,13 +6279,6 @@ def test_create_dlp_job(request_type, transport: str = "grpc"):
63016279
type_=dlp.DlpJobType.INSPECT_JOB,
63026280
state=dlp.DlpJob.JobState.PENDING,
63036281
job_trigger_name="job_trigger_name_value",
6304-
risk_details=dlp.AnalyzeDataSourceRiskDetails(
6305-
requested_privacy_metric=dlp.PrivacyMetric(
6306-
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
6307-
field=storage.FieldId(name="name_value")
6308-
)
6309-
)
6310-
),
63116282
)
63126283
response = client.create_dlp_job(request)
63136284

@@ -7005,9 +6976,11 @@ async def test_list_dlp_jobs_async_pages():
70056976
RuntimeError,
70066977
)
70076978
pages = []
7008-
async for page_ in (
6979+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
6980+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
6981+
async for page_ in ( # pragma: no branch
70096982
await client.list_dlp_jobs(request={})
7010-
).pages: # pragma: no branch
6983+
).pages:
70116984
pages.append(page_)
70126985
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
70136986
assert page_.raw_page.next_page_token == token
@@ -7038,13 +7011,6 @@ def test_get_dlp_job(request_type, transport: str = "grpc"):
70387011
type_=dlp.DlpJobType.INSPECT_JOB,
70397012
state=dlp.DlpJob.JobState.PENDING,
70407013
job_trigger_name="job_trigger_name_value",
7041-
risk_details=dlp.AnalyzeDataSourceRiskDetails(
7042-
requested_privacy_metric=dlp.PrivacyMetric(
7043-
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
7044-
field=storage.FieldId(name="name_value")
7045-
)
7046-
)
7047-
),
70487014
)
70497015
response = client.get_dlp_job(request)
70507016

@@ -8810,9 +8776,11 @@ async def test_list_stored_info_types_async_pages():
88108776
RuntimeError,
88118777
)
88128778
pages = []
8813-
async for page_ in (
8779+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
8780+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
8781+
async for page_ in ( # pragma: no branch
88148782
await client.list_stored_info_types(request={})
8815-
).pages: # pragma: no branch
8783+
).pages:
88168784
pages.append(page_)
88178785
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
88188786
assert page_.raw_page.next_page_token == token
@@ -13051,13 +13019,6 @@ def test_create_job_trigger_rest(request_type):
1305113019
display_name="display_name_value",
1305213020
description="description_value",
1305313021
status=dlp.JobTrigger.Status.HEALTHY,
13054-
inspect_job=dlp.InspectJobConfig(
13055-
storage_config=storage.StorageConfig(
13056-
datastore_options=storage.DatastoreOptions(
13057-
partition_id=storage.PartitionId(project_id="project_id_value")
13058-
)
13059-
)
13060-
),
1306113022
)
1306213023

1306313024
# Wrap the value into a proper Response obj
@@ -13337,13 +13298,6 @@ def test_update_job_trigger_rest(request_type):
1333713298
display_name="display_name_value",
1333813299
description="description_value",
1333913300
status=dlp.JobTrigger.Status.HEALTHY,
13340-
inspect_job=dlp.InspectJobConfig(
13341-
storage_config=storage.StorageConfig(
13342-
datastore_options=storage.DatastoreOptions(
13343-
partition_id=storage.PartitionId(project_id="project_id_value")
13344-
)
13345-
)
13346-
),
1334713301
)
1334813302

1334913303
# Wrap the value into a proper Response obj
@@ -13885,13 +13839,6 @@ def test_get_job_trigger_rest(request_type):
1388513839
display_name="display_name_value",
1388613840
description="description_value",
1388713841
status=dlp.JobTrigger.Status.HEALTHY,
13888-
inspect_job=dlp.InspectJobConfig(
13889-
storage_config=storage.StorageConfig(
13890-
datastore_options=storage.DatastoreOptions(
13891-
partition_id=storage.PartitionId(project_id="project_id_value")
13892-
)
13893-
)
13894-
),
1389513842
)
1389613843

1389713844
# Wrap the value into a proper Response obj
@@ -14749,13 +14696,6 @@ def test_activate_job_trigger_rest(request_type):
1474914696
type_=dlp.DlpJobType.INSPECT_JOB,
1475014697
state=dlp.DlpJob.JobState.PENDING,
1475114698
job_trigger_name="job_trigger_name_value",
14752-
risk_details=dlp.AnalyzeDataSourceRiskDetails(
14753-
requested_privacy_metric=dlp.PrivacyMetric(
14754-
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
14755-
field=storage.FieldId(name="name_value")
14756-
)
14757-
)
14758-
),
1475914699
)
1476014700

1476114701
# Wrap the value into a proper Response obj
@@ -14971,13 +14911,6 @@ def test_create_dlp_job_rest(request_type):
1497114911
type_=dlp.DlpJobType.INSPECT_JOB,
1497214912
state=dlp.DlpJob.JobState.PENDING,
1497314913
job_trigger_name="job_trigger_name_value",
14974-
risk_details=dlp.AnalyzeDataSourceRiskDetails(
14975-
requested_privacy_metric=dlp.PrivacyMetric(
14976-
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
14977-
field=storage.FieldId(name="name_value")
14978-
)
14979-
)
14980-
),
1498114914
)
1498214915

1498314916
# Wrap the value into a proper Response obj
@@ -15599,13 +15532,6 @@ def test_get_dlp_job_rest(request_type):
1559915532
type_=dlp.DlpJobType.INSPECT_JOB,
1560015533
state=dlp.DlpJob.JobState.PENDING,
1560115534
job_trigger_name="job_trigger_name_value",
15602-
risk_details=dlp.AnalyzeDataSourceRiskDetails(
15603-
requested_privacy_metric=dlp.PrivacyMetric(
15604-
numerical_stats_config=dlp.PrivacyMetric.NumericalStatsConfig(
15605-
field=storage.FieldId(name="name_value")
15606-
)
15607-
)
15608-
),
1560915535
)
1561015536

1561115537
# Wrap the value into a proper Response obj

0 commit comments

Comments
 (0)