Skip to content

Commit 448d4c7

Browse files
committed
chore: updates templates
1 parent 381cdbb commit 448d4c7

File tree

4 files changed

+311
-4
lines changed

4 files changed

+311
-4
lines changed

videointelligence/samples/analyze/noxfile.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
# You can opt out from the test for specific Python versions.
4040
'ignored_versions': ["2.7"],
4141

42+
# Old samples are opted out of enforcing Python type hints
43+
# All new samples should feature them
44+
'enforce_type_hints': False,
45+
4246
# An envvar key for determining the project id to use. Change it
4347
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4448
# build specific Cloud project. You can also use your own string
@@ -132,7 +136,10 @@ def _determine_local_import_names(start_dir):
132136

133137
@nox.session
134138
def lint(session):
135-
session.install("flake8", "flake8-import-order")
139+
if not TEST_CONFIG['enforce_type_hints']:
140+
session.install("flake8", "flake8-import-order")
141+
else:
142+
session.install("flake8", "flake8-import-order", "flake8-annotations")
136143

137144
local_names = _determine_local_import_names(".")
138145
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +148,18 @@ def lint(session):
141148
"."
142149
]
143150
session.run("flake8", *args)
151+
#
152+
# Black
153+
#
144154

145155

156+
@nox.session
157+
def blacken(session):
158+
session.install("black")
159+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
160+
161+
session.run("black", *python_files)
162+
146163
#
147164
# Sample Tests
148165
#
@@ -201,6 +218,11 @@ def _get_repo_root():
201218
break
202219
if Path(p / ".git").exists():
203220
return str(p)
221+
# .git is not available in repos cloned via Cloud Build
222+
# setup.py is always in the library's root, so use that instead
223+
# https://github.com/googleapis/synthtool/issues/792
224+
if Path(p / "setup.py").exists():
225+
return str(p)
204226
p = p.parent
205227
raise Exception("Unable to detect repository root.")
206228

videointelligence/samples/labels/noxfile.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
# You can opt out from the test for specific Python versions.
4040
'ignored_versions': ["2.7"],
4141

42+
# Old samples are opted out of enforcing Python type hints
43+
# All new samples should feature them
44+
'enforce_type_hints': False,
45+
4246
# An envvar key for determining the project id to use. Change it
4347
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4448
# build specific Cloud project. You can also use your own string
@@ -132,7 +136,10 @@ def _determine_local_import_names(start_dir):
132136

133137
@nox.session
134138
def lint(session):
135-
session.install("flake8", "flake8-import-order")
139+
if not TEST_CONFIG['enforce_type_hints']:
140+
session.install("flake8", "flake8-import-order")
141+
else:
142+
session.install("flake8", "flake8-import-order", "flake8-annotations")
136143

137144
local_names = _determine_local_import_names(".")
138145
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +148,18 @@ def lint(session):
141148
"."
142149
]
143150
session.run("flake8", *args)
151+
#
152+
# Black
153+
#
144154

145155

156+
@nox.session
157+
def blacken(session):
158+
session.install("black")
159+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
160+
161+
session.run("black", *python_files)
162+
146163
#
147164
# Sample Tests
148165
#
@@ -201,6 +218,11 @@ def _get_repo_root():
201218
break
202219
if Path(p / ".git").exists():
203220
return str(p)
221+
# .git is not available in repos cloned via Cloud Build
222+
# setup.py is always in the library's root, so use that instead
223+
# https://github.com/googleapis/synthtool/issues/792
224+
if Path(p / "setup.py").exists():
225+
return str(p)
204226
p = p.parent
205227
raise Exception("Unable to detect repository root.")
206228

videointelligence/samples/quickstart/README.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
.. This file is automatically generated. Do not edit this file directly.
23
34
Google Cloud Video Intelligence API Python Samples
@@ -14,10 +15,12 @@ This directory contains samples for Google Cloud Video Intelligence API. `Google
1415

1516
.. _Google Cloud Video Intelligence API: https://cloud.google.com/video-intelligence/docs
1617

18+
1719
Setup
1820
-------------------------------------------------------------------------------
1921

2022

23+
2124
Authentication
2225
++++++++++++++
2326

@@ -28,6 +31,9 @@ credentials for applications.
2831
.. _Authentication Getting Started Guide:
2932
https://cloud.google.com/docs/authentication/getting-started
3033

34+
35+
36+
3137
Install Dependencies
3238
++++++++++++++++++++
3339

@@ -42,7 +48,7 @@ Install Dependencies
4248
.. _Python Development Environment Setup Guide:
4349
https://cloud.google.com/python/setup
4450

45-
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
51+
#. Create a virtualenv. Samples are compatible with Python 3.6+.
4652

4753
.. code-block:: bash
4854
@@ -58,9 +64,15 @@ Install Dependencies
5864
.. _pip: https://pip.pypa.io/
5965
.. _virtualenv: https://virtualenv.pypa.io/
6066

67+
68+
69+
70+
71+
6172
Samples
6273
-------------------------------------------------------------------------------
6374

75+
6476
quickstart
6577
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6678

@@ -79,6 +91,10 @@ To run this sample:
7991
8092
8193
94+
95+
96+
97+
8298
The client library
8399
-------------------------------------------------------------------------------
84100

@@ -94,4 +110,5 @@ to `browse the source`_ and `report issues`_.
94110
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
95111

96112

97-
.. _Google Cloud SDK: https://cloud.google.com/sdk/
113+
114+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

0 commit comments

Comments
 (0)