Skip to content

Commit 2b65f3d

Browse files
author
Sylvain MARIE
committed
Fixed noxfile: shlex split does not handle windows backslash characters well. Wrapping in double quotes everywhere. Also using f-strings everywhere now.
1 parent a0b285e commit 2b65f3d

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

noxfile.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def tests(session: PowerSession, coverage, pkg_specs):
104104
# session.run2("conda list", env={"CONDA_PREFIX": str(conda_prefix), "CONDA_DEFAULT_ENV": session.get_session_id()})
105105

106106
# Fail if the assumed python version is not the actual one
107-
session.run2("python ci_tools/check_python_version.py %s" % session.python)
107+
session.run2(f"python ci_tools/check_python_version.py {session.python}")
108108

109109
# check that it can be imported even from a different folder
110110
# Important: do not surround the command into double quotes as in the shell !
@@ -127,20 +127,21 @@ def tests(session: PowerSession, coverage, pkg_specs):
127127
versions_dct=pkg_specs)
128128

129129
# --coverage + junit html reports
130-
session.run2("coverage run --source src/{pkg_name} "
131-
"-m pytest --cache-clear --junitxml={test_xml} --html={test_html} -v tests/"
132-
"".format(pkg_name=pkg_name, test_xml=Folders.test_xml, test_html=Folders.test_html))
130+
session.run2(f"coverage run --source src/{pkg_name} "
131+
f"-m pytest --cache-clear "
132+
f'--junitxml="{Folders.test_xml}" --html="{Folders.test_html}" '
133+
f"-v tests/")
133134
session.run2("coverage report")
134-
session.run2("coverage xml -o {covxml}".format(covxml=Folders.coverage_xml))
135-
session.run2("coverage html -d {dst}".format(dst=Folders.coverage_reports))
135+
session.run2(f'coverage xml -o "{Folders.coverage_xml}"')
136+
session.run2(f'coverage html -d "{Folders.coverage_reports}"')
136137
# delete this intermediate file, it is not needed anymore
137138
rm_file(Folders.coverage_intermediate_file)
138139

139140
# --generates the badge for the test results and fail build if less than x% tests pass
140141
nox_logger.info("Generating badge for tests coverage")
141142
# Use our own package to generate the badge
142-
session.run2("genbadge tests -i %s -o %s -t 100" % (Folders.test_xml, Folders.test_badge))
143-
session.run2("genbadge coverage -i %s -o %s" % (Folders.coverage_xml, Folders.coverage_badge))
143+
session.run2(f'genbadge tests -i "{Folders.test_xml}" -o "{Folders.test_badge}" -t 100')
144+
session.run2(f'genbadge coverage -i "{Folders.coverage_xml}" -o "{Folders.coverage_badge}"')
144145

145146

146147
@power_session(python=PY39, logsdir=Folders.runlogs)
@@ -160,21 +161,21 @@ def flake8(session: PowerSession):
160161
session.run("flake8", pkg_name, "--exit-zero", "--format=html", "--htmldir", str(Folders.flake8_reports),
161162
"--statistics", "--tee", "--output-file", str(Folders.flake8_intermediate_file))
162163
# generate our badge
163-
session.run2("genbadge flake8 -i %s -o %s" % (Folders.flake8_intermediate_file, Folders.flake8_badge))
164+
session.run2(f'genbadge flake8 -i "{Folders.flake8_intermediate_file}" -o "{Folders.flake8_badge}"')
164165
rm_file(Folders.flake8_intermediate_file)
165166

166167

167168
@power_session(python=[PY39])
168169
def docs(session: PowerSession):
169-
"""Generates the doc and serves it on a local http server. Pass '-- build' to build statically instead."""
170+
"""Generates the doc. Pass '-- serve' to serve it on a local http server instead."""
170171

171172
session.install_reqs(phase="docs", phase_reqs=["mkdocs-material", "mkdocs", "pymdown-extensions", "pygments"])
172173

173174
if session.posargs:
174-
# use posargs instead of "serve"
175+
# use posargs instead of "build"
175176
session.run2("mkdocs %s" % " ".join(session.posargs))
176177
else:
177-
session.run2("mkdocs serve")
178+
session.run2("mkdocs build")
178179

179180

180181
@power_session(python=[PY39])
@@ -251,10 +252,9 @@ def my_scheme(version_):
251252

252253
# create the github release
253254
session.install_reqs(phase="release", phase_reqs=["click", "PyGithub"])
254-
session.run2("python ci_tools/github_release.py -s {gh_token} "
255-
"--repo-slug {gh_org}/{gh_repo} -cf ./docs/changelog.md "
256-
"-d https://{gh_org}.github.io/{gh_repo}/changelog {tag}"
257-
"".format(gh_token=gh_token, gh_org=gh_org, gh_repo=gh_repo, tag=current_tag))
255+
session.run2(f"python ci_tools/github_release.py -s {gh_token} "
256+
f"--repo-slug {gh_org}/{gh_repo} -cf ./docs/changelog.md "
257+
f"-d https://{gh_org}.github.io/{gh_repo}/changelog {current_tag}")
258258

259259

260260
@nox.session(python=False)
@@ -283,15 +283,15 @@ def gha_list(session):
283283
session_func.parametrize
284284
except AttributeError:
285285
if additional_args.with_version:
286-
sessions_list = [{"python": py, "session": "%s-%s" % (session_func.__name__, py)} for py in session_func.python]
286+
sessions_list = [{"python": py, "session": f"{session_func.__name__}-{py}"} for py in session_func.python]
287287
else:
288-
sessions_list = ["%s-%s" % (session_func.__name__, py) for py in session_func.python]
288+
sessions_list = [f"{session_func.__name__}-{py}" for py in session_func.python]
289289
else:
290290
if additional_args.with_version:
291-
sessions_list = [{"python": py, "session": "%s-%s(%s)" % (session_func.__name__, py, param)}
291+
sessions_list = [{"python": py, "session": f"{session_func.__name__}-{py}({param})"}
292292
for py, param in product(session_func.python, session_func.parametrize)]
293293
else:
294-
sessions_list = ["%s-%s(%s)" % (session_func.__name__, py, param)
294+
sessions_list = [f"{session_func.__name__}-{py}({param})"
295295
for py, param in product(session_func.python, session_func.parametrize)]
296296

297297
# print the list so that it can be caught by GHA.

0 commit comments

Comments
 (0)