Skip to content

Commit

Permalink
chore: update templates (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored Dec 3, 2020
1 parent f53ce71 commit df818a6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion secretmanager/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],

# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
'enforce_type_hints': False,

# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
Expand Down Expand Up @@ -132,7 +136,10 @@ def _determine_local_import_names(start_dir):

@nox.session
def lint(session):
session.install("flake8", "flake8-import-order")
if not TEST_CONFIG['enforce_type_hints']:
session.install("flake8", "flake8-import-order")
else:
session.install("flake8", "flake8-import-order", "flake8-annotations")

local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
Expand All @@ -141,8 +148,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
#
# Black
#


@nox.session
def blacken(session):
session.install("black")
python_files = [path for path in os.listdir(".") if path.endswith(".py")]

session.run("black", *python_files)

#
# Sample Tests
#
Expand Down Expand Up @@ -201,6 +218,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
# .git is not available in repos cloned via Cloud Build
# setup.py is always in the library's root, so use that instead
# https://github.com/googleapis/synthtool/issues/792
if Path(p / "setup.py").exists():
return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")

Expand Down

0 comments on commit df818a6

Please sign in to comment.