Skip to content

Commit c1d56c1

Browse files
committed
chore: lints and blackens
1 parent 448d4c7 commit c1d56c1

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed

videointelligence/samples/quickstart/noxfile.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,25 @@
3737

3838
TEST_CONFIG = {
3939
# You can opt out from the test for specific Python versions.
40-
'ignored_versions': ["2.7"],
41-
40+
"ignored_versions": ["2.7"],
4241
# Old samples are opted out of enforcing Python type hints
4342
# All new samples should feature them
44-
'enforce_type_hints': False,
45-
43+
"enforce_type_hints": False,
4644
# An envvar key for determining the project id to use. Change it
4745
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4846
# build specific Cloud project. You can also use your own string
4947
# to use your own Cloud project.
50-
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
48+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
5149
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
52-
5350
# A dictionary you want to inject into your test. Don't put any
5451
# secrets here. These values will override predefined values.
55-
'envs': {},
52+
"envs": {},
5653
}
5754

5855

5956
try:
6057
# Ensure we can import noxfile_config in the project's directory.
61-
sys.path.append('.')
58+
sys.path.append(".")
6259
from noxfile_config import TEST_CONFIG_OVERRIDE
6360
except ImportError as e:
6461
print("No user noxfile_config found: detail: {}".format(e))
@@ -73,12 +70,12 @@ def get_pytest_env_vars():
7370
ret = {}
7471

7572
# Override the GCLOUD_PROJECT and the alias.
76-
env_key = TEST_CONFIG['gcloud_project_env']
73+
env_key = TEST_CONFIG["gcloud_project_env"]
7774
# This should error out if not set.
78-
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
75+
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]
7976

8077
# Apply user supplied envs.
81-
ret.update(TEST_CONFIG['envs'])
78+
ret.update(TEST_CONFIG["envs"])
8279
return ret
8380

8481

@@ -87,7 +84,7 @@ def get_pytest_env_vars():
8784
ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8"]
8885

8986
# Any default versions that should be ignored.
90-
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
87+
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
9188

9289
TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])
9390

@@ -136,7 +133,7 @@ def _determine_local_import_names(start_dir):
136133

137134
@nox.session
138135
def lint(session):
139-
if not TEST_CONFIG['enforce_type_hints']:
136+
if not TEST_CONFIG["enforce_type_hints"]:
140137
session.install("flake8", "flake8-import-order")
141138
else:
142139
session.install("flake8", "flake8-import-order", "flake8-annotations")
@@ -145,9 +142,11 @@ def lint(session):
145142
args = FLAKE8_COMMON_ARGS + [
146143
"--application-import-names",
147144
",".join(local_names),
148-
"."
145+
".",
149146
]
150147
session.run("flake8", *args)
148+
149+
151150
#
152151
# Black
153152
#
@@ -160,6 +159,7 @@ def blacken(session):
160159

161160
session.run("black", *python_files)
162161

162+
163163
#
164164
# Sample Tests
165165
#
@@ -199,9 +199,9 @@ def py(session):
199199
if session.python in TESTED_VERSIONS:
200200
_session_tests(session)
201201
else:
202-
session.skip("SKIPPED: {} tests are disabled for this sample.".format(
203-
session.python
204-
))
202+
session.skip(
203+
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
204+
)
205205

206206

207207
#

videointelligence/samples/quickstart/quickstart.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,38 @@ def run_quickstart():
3030
video_client = videointelligence.VideoIntelligenceServiceClient()
3131
features = [videointelligence.enums.Feature.LABEL_DETECTION]
3232
operation = video_client.annotate_video(
33-
'gs://cloud-samples-data/video/cat.mp4', features=features)
34-
print('\nProcessing video for label annotations:')
33+
"gs://cloud-samples-data/video/cat.mp4", features=features
34+
)
35+
print("\nProcessing video for label annotations:")
3536

3637
result = operation.result(timeout=120)
37-
print('\nFinished processing.')
38+
print("\nFinished processing.")
3839

3940
# first result is retrieved because a single video was processed
4041
segment_labels = result.annotation_results[0].segment_label_annotations
4142
for i, segment_label in enumerate(segment_labels):
42-
print('Video label description: {}'.format(
43-
segment_label.entity.description))
43+
print("Video label description: {}".format(segment_label.entity.description))
4444
for category_entity in segment_label.category_entities:
45-
print('\tLabel category description: {}'.format(
46-
category_entity.description))
45+
print(
46+
"\tLabel category description: {}".format(category_entity.description)
47+
)
4748

4849
for i, segment in enumerate(segment_label.segments):
49-
start_time = (segment.segment.start_time_offset.seconds +
50-
segment.segment.start_time_offset.nanos / 1e9)
51-
end_time = (segment.segment.end_time_offset.seconds +
52-
segment.segment.end_time_offset.nanos / 1e9)
53-
positions = '{}s to {}s'.format(start_time, end_time)
50+
start_time = (
51+
segment.segment.start_time_offset.seconds
52+
+ segment.segment.start_time_offset.nanos / 1e9
53+
)
54+
end_time = (
55+
segment.segment.end_time_offset.seconds
56+
+ segment.segment.end_time_offset.nanos / 1e9
57+
)
58+
positions = "{}s to {}s".format(start_time, end_time)
5459
confidence = segment.confidence
55-
print('\tSegment {}: {}'.format(i, positions))
56-
print('\tConfidence: {}'.format(confidence))
57-
print('\n')
60+
print("\tSegment {}: {}".format(i, positions))
61+
print("\tConfidence: {}".format(confidence))
62+
print("\n")
5863
# [END video_quickstart]
5964

6065

61-
if __name__ == '__main__':
66+
if __name__ == "__main__":
6267
run_quickstart()

videointelligence/samples/quickstart/quickstart_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
def test_quickstart(capsys):
2424
quickstart.run_quickstart()
2525
out, _ = capsys.readouterr()
26-
assert 'Video label description: cat' in out
26+
assert "Video label description: cat" in out

0 commit comments

Comments
 (0)