Skip to content

Commit cfb490a

Browse files
chore(python): use black==22.3.0 (#359)
Source-Link: googleapis/synthtool@6fab84a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
1 parent c08e9dd commit cfb490a

File tree

12 files changed

+139
-49
lines changed

12 files changed

+139
-49
lines changed

dlp/snippets/custom_infotype.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ def inspect_string_custom_omit_overlap(project, content_string):
408408

409409
# [START dlp_omit_name_if_also_email]
410410
def omit_name_if_also_email(
411-
project, content_string,
411+
project,
412+
content_string,
412413
):
413414
"""Matches PERSON_NAME and EMAIL_ADDRESS, but not both.
414415
@@ -731,7 +732,8 @@ def inspect_string_multiple_rules(project, content_string):
731732

732733
# [START dlp_inspect_with_medical_record_number_custom_regex_detector]
733734
def inspect_with_medical_record_number_custom_regex_detector(
734-
project, content_string,
735+
project,
736+
content_string,
735737
):
736738
"""Uses the Data Loss Prevention API to analyze string with medical record
737739
number custom regex detector
@@ -793,7 +795,8 @@ def inspect_with_medical_record_number_custom_regex_detector(
793795

794796
# [START dlp_inspect_with_medical_record_number_w_custom_hotwords]
795797
def inspect_with_medical_record_number_w_custom_hotwords(
796-
project, content_string,
798+
project,
799+
content_string,
797800
):
798801
"""Uses the Data Loss Prevention API to analyze string with medical record
799802
number custom regex detector, with custom hotwords rules to boost finding

dlp/snippets/deid.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def deidentify_with_mask(
8585

8686
# [START dlp_deidentify_redact]
8787
def deidentify_with_redact(
88-
project, input_str, info_types,
88+
project,
89+
input_str,
90+
info_types,
8991
):
9092
"""Uses the Data Loss Prevention API to deidentify sensitive data in a
9193
string by redacting matched input values.
@@ -135,7 +137,10 @@ def deidentify_with_redact(
135137

136138
# [START dlp_deidentify_replace]
137139
def deidentify_with_replace(
138-
project, input_str, info_types, replacement_str="REPLACEMENT_STR",
140+
project,
141+
input_str,
142+
info_types,
143+
replacement_str="REPLACEMENT_STR",
139144
):
140145
"""Uses the Data Loss Prevention API to deidentify sensitive data in a
141146
string by replacing matched input values with a value you specify.
@@ -471,7 +476,11 @@ def reidentify_with_fpe(
471476

472477
# [START dlp_reidentify_deterministic]
473478
def reidentify_with_deterministic(
474-
project, input_str, surrogate_type=None, key_name=None, wrapped_key=None,
479+
project,
480+
input_str,
481+
surrogate_type=None,
482+
key_name=None,
483+
wrapped_key=None,
475484
):
476485
"""Re-identifies content that was previously de-identified through deterministic encryption.
477486
Args:
@@ -949,7 +958,8 @@ def deidentify_with_replace_infotype(project, item, info_types):
949958
default=["FIRST_NAME", "LAST_NAME", "EMAIL_ADDRESS"],
950959
)
951960
mask_parser.add_argument(
952-
"project", help="The Google Cloud project id to use as a parent resource.",
961+
"project",
962+
help="The Google Cloud project id to use as a parent resource.",
953963
)
954964
mask_parser.add_argument("item", help="The string to deidentify.")
955965
mask_parser.add_argument(
@@ -982,7 +992,8 @@ def deidentify_with_replace_infotype(project, item, info_types):
982992
default=["FIRST_NAME", "LAST_NAME", "EMAIL_ADDRESS"],
983993
)
984994
replace_parser.add_argument(
985-
"project", help="The Google Cloud project id to use as a parent resource.",
995+
"project",
996+
help="The Google Cloud project id to use as a parent resource.",
986997
)
987998
replace_parser.add_argument("item", help="The string to deidentify.")
988999
replace_parser.add_argument(
@@ -1004,7 +1015,8 @@ def deidentify_with_replace_infotype(project, item, info_types):
10041015
default=["FIRST_NAME", "LAST_NAME", "EMAIL_ADDRESS"],
10051016
)
10061017
fpe_parser.add_argument(
1007-
"project", help="The Google Cloud project id to use as a parent resource.",
1018+
"project",
1019+
help="The Google Cloud project id to use as a parent resource.",
10081020
)
10091021
fpe_parser.add_argument(
10101022
"item",
@@ -1046,7 +1058,8 @@ def deidentify_with_replace_infotype(project, item, info_types):
10461058
"Encryption (FPE).",
10471059
)
10481060
reid_parser.add_argument(
1049-
"project", help="The Google Cloud project id to use as a parent resource.",
1061+
"project",
1062+
help="The Google Cloud project id to use as a parent resource.",
10501063
)
10511064
reid_parser.add_argument(
10521065
"item",
@@ -1086,7 +1099,8 @@ def deidentify_with_replace_infotype(project, item, info_types):
10861099
help="Deidentify dates in a CSV file by pseudorandomly shifting them.",
10871100
)
10881101
date_shift_parser.add_argument(
1089-
"project", help="The Google Cloud project id to use as a parent resource.",
1102+
"project",
1103+
help="The Google Cloud project id to use as a parent resource.",
10901104
)
10911105
date_shift_parser.add_argument(
10921106
"input_csv_file",
@@ -1149,7 +1163,8 @@ def deidentify_with_replace_infotype(project, item, info_types):
11491163
default=["FIRST_NAME", "LAST_NAME", "EMAIL_ADDRESS"],
11501164
)
11511165
replace_with_infotype_parser.add_argument(
1152-
"project", help="The Google Cloud project id to use as a parent resource.",
1166+
"project",
1167+
help="The Google Cloud project id to use as a parent resource.",
11531168
)
11541169
replace_with_infotype_parser.add_argument(
11551170
"item",
@@ -1207,5 +1222,7 @@ def deidentify_with_replace_infotype(project, item, info_types):
12071222
)
12081223
elif args.content == "replace_with_infotype":
12091224
deidentify_with_replace_infotype(
1210-
args.project, item=args.item, info_types=args.info_types,
1225+
args.project,
1226+
item=args.item,
1227+
info_types=args.info_types,
12111228
)

dlp/snippets/deid_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def test_deidentify_with_mask_masking_character_specified(capsys):
8181

8282
def test_deidentify_with_mask_masking_number_specified(capsys):
8383
deid.deidentify_with_mask(
84-
GCLOUD_PROJECT, HARMFUL_STRING, ["US_SOCIAL_SECURITY_NUMBER"], number_to_mask=7,
84+
GCLOUD_PROJECT,
85+
HARMFUL_STRING,
86+
["US_SOCIAL_SECURITY_NUMBER"],
87+
number_to_mask=7,
8588
)
8689

8790
out, _ = capsys.readouterr()
@@ -278,7 +281,9 @@ def test_reidentify_free_text_with_fpe_using_surrogate(capsys):
278281
def test_deidentify_with_replace_infotype(capsys):
279282
url_to_redact = "https://cloud.google.com"
280283
deid.deidentify_with_replace_infotype(
281-
GCLOUD_PROJECT, "My favorite site is " + url_to_redact, ["URL"],
284+
GCLOUD_PROJECT,
285+
"My favorite site is " + url_to_redact,
286+
["URL"],
282287
)
283288

284289
out, _ = capsys.readouterr()

dlp/snippets/inspect_content.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
# [START dlp_inspect_string_basic]
2626
def inspect_string_basic(
27-
project, content_string, info_types=["PHONE_NUMBER"],
27+
project,
28+
content_string,
29+
info_types=["PHONE_NUMBER"],
2830
):
2931
"""Uses the Data Loss Prevention API to analyze strings for protected data.
3032
Args:
@@ -1197,7 +1199,8 @@ def callback(message):
11971199
help="The Google Cloud project id of the target Datastore.",
11981200
)
11991201
parser_datastore.add_argument(
1200-
"kind", help='The kind of the Datastore entity to inspect, e.g. "Person".',
1202+
"kind",
1203+
help='The kind of the Datastore entity to inspect, e.g. "Person".',
12011204
)
12021205
parser_datastore.add_argument(
12031206
"topic_id",
@@ -1273,7 +1276,8 @@ def callback(message):
12731276
"bigquery", help="Inspect files on Google BigQuery."
12741277
)
12751278
parser_bigquery.add_argument(
1276-
"bigquery_project", help="The Google Cloud project id of the target table.",
1279+
"bigquery_project",
1280+
help="The Google Cloud project id of the target table.",
12771281
)
12781282
parser_bigquery.add_argument(
12791283
"dataset_id", help="The ID of the target BigQuery dataset."

dlp/snippets/inspect_content_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def bigquery_project():
159159
except google.api_core.exceptions.Conflict:
160160
table = bigquery_client.get_table(table)
161161

162-
rows_to_insert = [(u"Gary Smith", u"My email is [email protected]")]
162+
rows_to_insert = [("Gary Smith", "My email is [email protected]")]
163163

164164
bigquery_client.insert_rows(table, rows_to_insert)
165165

dlp/snippets/metadata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def list_info_types(language_code=None, result_filter=None):
4646
print("Info types:")
4747
for info_type in response.info_types:
4848
print(
49-
u"{name}: {display_name}".format(
49+
"{name}: {display_name}".format(
5050
name=info_type.name, display_name=info_type.display_name
5151
)
5252
)
@@ -58,7 +58,8 @@ def list_info_types(language_code=None, result_filter=None):
5858
if __name__ == "__main__":
5959
parser = argparse.ArgumentParser(description=__doc__)
6060
parser.add_argument(
61-
"--language_code", help="The BCP-47 language code to use, e.g. 'en-US'.",
61+
"--language_code",
62+
help="The BCP-47 language code to use, e.g. 'en-US'.",
6263
)
6364
parser.add_argument(
6465
"--filter",

dlp/snippets/noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# WARNING - WARNING - WARNING - WARNING - WARNING
3030
# WARNING - WARNING - WARNING - WARNING - WARNING
3131

32-
BLACK_VERSION = "black==19.10b0"
32+
BLACK_VERSION = "black==22.3.0"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None:
253253

254254

255255
def _get_repo_root() -> Optional[str]:
256-
""" Returns the root folder of the project. """
256+
"""Returns the root folder of the project."""
257257
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
258258
p = Path(os.getcwd())
259259
for i in range(10):

dlp/snippets/redact.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030

3131

3232
def redact_image(
33-
project, filename, output_filename, info_types, min_likelihood=None, mime_type=None,
33+
project,
34+
filename,
35+
output_filename,
36+
info_types,
37+
min_likelihood=None,
38+
mime_type=None,
3439
):
3540
"""Uses the Data Loss Prevention API to redact protected data in an image.
3641
Args:
@@ -122,7 +127,9 @@ def redact_image(
122127

123128

124129
def redact_image_all_text(
125-
project, filename, output_filename,
130+
project,
131+
filename,
132+
output_filename,
126133
):
127134
"""Uses the Data Loss Prevention API to redact all text in an image.
128135
@@ -184,7 +191,8 @@ def redact_image_all_text(
184191
)
185192
common_args_parser.add_argument("filename", help="The path to the file to inspect.")
186193
common_args_parser.add_argument(
187-
"output_filename", help="The path to which the redacted image will be written.",
194+
"output_filename",
195+
help="The path to which the redacted image will be written.",
188196
)
189197

190198
parser = argparse.ArgumentParser(description=__doc__)
@@ -246,5 +254,7 @@ def redact_image_all_text(
246254
)
247255
elif args.content == "all_text":
248256
redact_image_all_text(
249-
args.project, args.filename, args.output_filename,
257+
args.project,
258+
args.filename,
259+
args.output_filename,
250260
)

dlp/snippets/redact_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ def test_redact_image_file(tempdir, capsys):
3636
output_filepath = os.path.join(tempdir, "redacted.png")
3737

3838
redact.redact_image(
39-
GCLOUD_PROJECT, test_filepath, output_filepath, ["FIRST_NAME", "EMAIL_ADDRESS"],
39+
GCLOUD_PROJECT,
40+
test_filepath,
41+
output_filepath,
42+
["FIRST_NAME", "EMAIL_ADDRESS"],
4043
)
4144

4245
out, _ = capsys.readouterr()
@@ -48,7 +51,9 @@ def test_redact_image_all_text(tempdir, capsys):
4851
output_filepath = os.path.join(tempdir, "redacted.png")
4952

5053
redact.redact_image_all_text(
51-
GCLOUD_PROJECT, test_filepath, output_filepath,
54+
GCLOUD_PROJECT,
55+
test_filepath,
56+
output_filepath,
5257
)
5358

5459
out, _ = capsys.readouterr()

0 commit comments

Comments
 (0)