aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com>2021-09-17 15:36:36 +0000
committerGitHub <noreply@github.com>2021-09-17 15:36:36 +0000
commit167f8609eb16cbac77ca43720a18c860d130c1d6 (patch)
tree317c927565d11899c4bb6393953916f5d08edcdc
parente647d80ff11cc2229c92e230b4f00860c00735b4 (diff)
downloadgoogle-api-python-client-167f8609eb16cbac77ca43720a18c860d130c1d6.tar.gz
chore: blacken samples noxfile template (#1529)
-rw-r--r--.github/.OwlBot.lock.yaml2
-rw-r--r--samples/compute/noxfile.py44
2 files changed, 26 insertions, 20 deletions
diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index c07f148f0..e2c237774 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -1,3 +1,3 @@
docker:
image: gcr.io/repo-automation-bots/owlbot-python:latest
- digest: sha256:0ffe3bdd6c7159692df5f7744da74e5ef19966288a6bf76023e8e04e0c424d7d
+ digest: sha256:0ccd9f4d714d36e311f60f407199dd460e43a99a125b5ca64b1d75f6e5f8581b
diff --git a/samples/compute/noxfile.py b/samples/compute/noxfile.py
index e73436a15..b008613f0 100644
--- a/samples/compute/noxfile.py
+++ b/samples/compute/noxfile.py
@@ -39,17 +39,15 @@ BLACK_VERSION = "black==19.10b0"
TEST_CONFIG = {
# You can opt out from the test for specific Python versions.
- 'ignored_versions': [],
-
+ "ignored_versions": [],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
- 'enforce_type_hints': False,
-
+ "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
# to use your own Cloud project.
- 'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
+ "gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
# If you need to use a specific version of pip,
# change pip_version_override to the string representation
@@ -57,13 +55,13 @@ TEST_CONFIG = {
"pip_version_override": None,
# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
- 'envs': {},
+ "envs": {},
}
try:
# Ensure we can import noxfile_config in the project's directory.
- sys.path.append('.')
+ sys.path.append(".")
from noxfile_config import TEST_CONFIG_OVERRIDE
except ImportError as e:
print("No user noxfile_config found: detail: {}".format(e))
@@ -78,12 +76,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
ret = {}
# Override the GCLOUD_PROJECT and the alias.
- env_key = TEST_CONFIG['gcloud_project_env']
+ env_key = TEST_CONFIG["gcloud_project_env"]
# This should error out if not set.
- ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
+ ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]
# Apply user supplied envs.
- ret.update(TEST_CONFIG['envs'])
+ ret.update(TEST_CONFIG["envs"])
return ret
@@ -92,11 +90,14 @@ def get_pytest_env_vars() -> Dict[str, str]:
ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
# Any default versions that should be ignored.
-IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
+IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])
-INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ("True", "true")
+INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in (
+ "True",
+ "true",
+)
#
# Style Checks
#
@@ -141,7 +142,7 @@ FLAKE8_COMMON_ARGS = [
@nox.session
def lint(session: nox.sessions.Session) -> None:
- if not TEST_CONFIG['enforce_type_hints']:
+ if not TEST_CONFIG["enforce_type_hints"]:
session.install("flake8", "flake8-import-order")
else:
session.install("flake8", "flake8-import-order", "flake8-annotations")
@@ -150,9 +151,11 @@ def lint(session: nox.sessions.Session) -> None:
args = FLAKE8_COMMON_ARGS + [
"--application-import-names",
",".join(local_names),
- "."
+ ".",
]
session.run("flake8", *args)
+
+
#
# Black
#
@@ -165,6 +168,7 @@ def blacken(session: nox.sessions.Session) -> None:
session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -173,7 +177,9 @@ def blacken(session: nox.sessions.Session) -> None:
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
+def _session_tests(
+ session: nox.sessions.Session, post_install: Callable = None
+) -> None:
if TEST_CONFIG["pip_version_override"]:
pip_version = TEST_CONFIG["pip_version_override"]
session.install(f"pip=={pip_version}")
@@ -203,7 +209,7 @@ def _session_tests(session: nox.sessions.Session, post_install: Callable = None)
# on travis where slow and flaky tests are excluded.
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
success_codes=[0, 5],
- env=get_pytest_env_vars()
+ env=get_pytest_env_vars(),
)
@@ -213,9 +219,9 @@ def py(session: nox.sessions.Session) -> None:
if session.python in TESTED_VERSIONS:
_session_tests(session)
else:
- session.skip("SKIPPED: {} tests are disabled for this sample.".format(
- session.python
- ))
+ session.skip(
+ "SKIPPED: {} tests are disabled for this sample.".format(session.python)
+ )
#