Skip to content

Commit c6777a4

Browse files
chore(python): use ubuntu 22.04 in docs image (#377)
Source-Link: googleapis/synthtool@f15cc72 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd
1 parent d43441a commit c6777a4

8 files changed

+31
-16
lines changed

dlp/snippets/deid_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import tempfile
1818

1919
import google.cloud.dlp_v2
20-
2120
import pytest
2221

2322
import deid

dlp/snippets/inspect_content.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,15 +466,15 @@ def inspect_gcs_file(
466466
"""
467467

468468
# Import the client library.
469+
# This sample also uses threading.Event() to wait for the job to finish.
470+
import threading
471+
469472
import google.cloud.dlp
470473

471474
# This sample additionally uses Cloud Pub/Sub to receive results from
472475
# potentially long-running operations.
473476
import google.cloud.pubsub
474477

475-
# This sample also uses threading.Event() to wait for the job to finish.
476-
import threading
477-
478478
# Instantiate a client.
479479
dlp = google.cloud.dlp_v2.DlpServiceClient()
480480

@@ -626,15 +626,15 @@ def inspect_datastore(
626626
"""
627627

628628
# Import the client library.
629+
# This sample also uses threading.Event() to wait for the job to finish.
630+
import threading
631+
629632
import google.cloud.dlp
630633

631634
# This sample additionally uses Cloud Pub/Sub to receive results from
632635
# potentially long-running operations.
633636
import google.cloud.pubsub
634637

635-
# This sample also uses threading.Event() to wait for the job to finish.
636-
import threading
637-
638638
# Instantiate a client.
639639
dlp = google.cloud.dlp_v2.DlpServiceClient()
640640

@@ -796,15 +796,15 @@ def inspect_bigquery(
796796
"""
797797

798798
# Import the client library.
799+
# This sample also uses threading.Event() to wait for the job to finish.
800+
import threading
801+
799802
import google.cloud.dlp
800803

801804
# This sample additionally uses Cloud Pub/Sub to receive results from
802805
# potentially long-running operations.
803806
import google.cloud.pubsub
804807

805-
# This sample also uses threading.Event() to wait for the job to finish.
806-
import threading
807-
808808
# Instantiate a client.
809809
dlp = google.cloud.dlp_v2.DlpServiceClient()
810810

dlp/snippets/inspect_content_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import inspect_content
3030

31-
3231
UNIQUE_STRING = str(uuid.uuid4()).split("-")[0]
3332

3433
GCLOUD_PROJECT = os.getenv("GOOGLE_CLOUD_PROJECT")

dlp/snippets/noxfile.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import nox
2424

25-
2625
# WARNING - WARNING - WARNING - WARNING - WARNING
2726
# WARNING - WARNING - WARNING - WARNING - WARNING
2827
# DO NOT EDIT THIS FILE EVER!
2928
# WARNING - WARNING - WARNING - WARNING - WARNING
3029
# WARNING - WARNING - WARNING - WARNING - WARNING
3130

3231
BLACK_VERSION = "black==22.3.0"
32+
ISORT_VERSION = "isort==5.10.1"
3333

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

@@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None:
168168

169169
@nox.session
170170
def blacken(session: nox.sessions.Session) -> None:
171+
"""Run black. Format code to uniform standard."""
171172
session.install(BLACK_VERSION)
172173
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
173174

174175
session.run("black", *python_files)
175176

176177

178+
#
179+
# format = isort + black
180+
#
181+
182+
183+
@nox.session
184+
def format(session: nox.sessions.Session) -> None:
185+
"""
186+
Run isort to sort imports. Then run black
187+
to format code to uniform standard.
188+
"""
189+
session.install(BLACK_VERSION, ISORT_VERSION)
190+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
191+
192+
# Use the --fss option to sort imports using strict alphabetical order.
193+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
194+
session.run("isort", "--fss", *python_files)
195+
session.run("black", *python_files)
196+
197+
177198
#
178199
# Sample Tests
179200
#

dlp/snippets/quickstart_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import quickstart
1818

19-
2019
GCLOUD_PROJECT = os.getenv("GOOGLE_CLOUD_PROJECT")
2120

2221

dlp/snippets/redact.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
# [END dlp_redact_image]
2626
import os
2727

28-
2928
# [START dlp_redact_image]
3029

3130

dlp/snippets/risk_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import risk
2323

24-
2524
UNIQUE_STRING = str(uuid.uuid4()).split("-")[0]
2625
GCLOUD_PROJECT = os.environ.get("GOOGLE_CLOUD_PROJECT")
2726
TABLE_PROJECT = os.environ.get("GOOGLE_CLOUD_PROJECT")

dlp/snippets/triggers_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import google.api_core.exceptions
1919
import google.cloud.storage
20-
2120
import pytest
2221

2322
import triggers

0 commit comments

Comments
 (0)