Skip to content

Commit 903229b

Browse files
yoshi-automationdandhlee
authored andcommitted
chore: update templates (#58)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/6c49b023-73d4-4d21-9e9f-028a9067e602/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@32af6da Source-Link: googleapis/synthtool@a073c87 Source-Link: googleapis/synthtool@9a7d9fb Source-Link: googleapis/synthtool@e89175c Source-Link: googleapis/synthtool@1f1148d Source-Link: googleapis/synthtool@3d3e94c Source-Link: googleapis/synthtool@6542bd7 Source-Link: googleapis/synthtool@ea52b8a Source-Link: googleapis/synthtool@5f6ef0e Source-Link: googleapis/synthtool@da5c605 Source-Link: googleapis/synthtool@477764c Source-Link: googleapis/synthtool@e0ae456 Source-Link: googleapis/synthtool@9b0da52 Source-Link: googleapis/synthtool@a651c5f Source-Link: googleapis/synthtool@27f4406 Source-Link: googleapis/synthtool@dba48bb Source-Link: googleapis/synthtool@257fda1
1 parent c3ddc95 commit 903229b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

secretmanager/snippets/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

0 commit comments

Comments
 (0)