Skip to content

Commit cb0c683

Browse files
committed
chore: add changes to adhere to linting and formatting from within the generated result
1 parent fa3fde2 commit cb0c683

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import os
44
import shlex
5-
65
from pathlib import Path
76
from textwrap import dedent
87
from typing import List
@@ -50,9 +49,7 @@
5049
@nox.session(python=None, name="setup-git", tags=[ENV])
5150
def setup_git(session: Session) -> None:
5251
"""Set up the git repo for the current project."""
53-
session.run(
54-
"python", SCRIPTS_FOLDER / "setup-git.py", REPO_ROOT, external=True
55-
)
52+
session.run("python", SCRIPTS_FOLDER / "setup-git.py", REPO_ROOT, external=True)
5653

5754

5855
@nox.session(python=None, name="setup-venv", tags=[ENV])
@@ -61,7 +58,6 @@ def setup_venv(session: Session) -> None:
6158
session.run("python", SCRIPTS_FOLDER / "setup-venv.py", REPO_ROOT, "-p", PYTHON_VERSIONS[0], external=True)
6259

6360

64-
6561
@nox.session(python=DEFAULT_PYTHON_VERSION, name="pre-commit", tags=[CI])
6662
def precommit(session: Session) -> None:
6763
"""Lint using pre-commit."""
@@ -161,13 +157,7 @@ def tests_python(session: Session) -> None:
161157
test_results_dir.mkdir(parents=True, exist_ok=True)
162158
junitxml_file = test_results_dir / f"test-results-py{session.python}.xml"
163159

164-
session.run(
165-
"pytest",
166-
"--cov={}".format(PACKAGE_NAME),
167-
"--cov-report=xml",
168-
f"--junitxml={junitxml_file}",
169-
"tests/"
170-
)
160+
session.run("pytest", "--cov={}".format(PACKAGE_NAME), "--cov-report=xml", f"--junitxml={junitxml_file}", "tests/")
171161

172162

173163
{% if cookiecutter.add_rust_extension == 'y' -%}
@@ -242,7 +232,15 @@ def build_container(session: Session) -> None:
242232

243233
session.log(f"Building Docker image using {container_cli}.")
244234
project_image_name = PACKAGE_NAME.replace("_", "-").lower()
245-
session.run(container_cli, "build", str(current_dir), "-t", f"{project_image_name}:latest", "--progress=plain", external=True)
235+
session.run(
236+
container_cli,
237+
"build",
238+
str(current_dir),
239+
"-t",
240+
f"{project_image_name}:latest",
241+
"--progress=plain",
242+
external=True,
243+
)
246244

247245
session.log(f"Container image {project_image_name}:latest built locally.")
248246

@@ -302,15 +300,13 @@ def release(session: Session) -> None:
302300
cz_bump_args = ["uvx", "cz", "bump", "--changelog"]
303301

304302
if increment:
305-
cz_bump_args.append(f"--increment={increment}")
303+
cz_bump_args.append(f"--increment={increment}")
306304

307305
session.log("Running cz bump with args: %s", cz_bump_args)
308306
session.run(*cz_bump_args, success_codes=[0, 1], external=True)
309307

310308
session.log("Version bumped and tag created locally via Commitizen/uvx.")
311-
session.log(
312-
"IMPORTANT: Push commits and tags to remote (`git push --follow-tags`) to trigger CD pipeline."
313-
)
309+
session.log("IMPORTANT: Push commits and tags to remote (`git push --follow-tags`) to trigger CD pipeline.")
314310

315311

316312
@nox.session(venv_backend="none")
@@ -344,7 +340,9 @@ def coverage(session: Session) -> None:
344340
(e.g., via `nox -s test-python`).
345341
"""
346342
session.log("Collecting and reporting coverage across all test runs.")
347-
session.log("Note: Ensure 'nox -s test-python' was run across all desired Python versions first to generate coverage data.")
343+
session.log(
344+
"Note: Ensure 'nox -s test-python' was run across all desired Python versions first to generate coverage data."
345+
)
348346

349347
session.log("Installing dependencies for coverage report session...")
350348
session.install("-e", ".", "--group", "dev")
@@ -357,9 +355,9 @@ def coverage(session: Session) -> None:
357355
session.log(f"Combined coverage data into {coverage_combined_file.resolve()}")
358356
except CommandFailed as e:
359357
if e.returncode == 1:
360-
session.log("No coverage data found to combine. Run tests first with coverage enabled.")
358+
session.log("No coverage data found to combine. Run tests first with coverage enabled.")
361359
else:
362-
session.error(f"Failed to combine coverage data: {e}")
360+
session.error(f"Failed to combine coverage data: {e}")
363361
session.skip("Could not combine coverage data.")
364362

365363
session.log("Generating HTML coverage report.")

{{cookiecutter.project_name}}/scripts/setup-git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Since this is a first time setup script, we intentionally only use builtin Python dependencies.
44
"""
5+
56
import argparse
67
import subprocess
78
from pathlib import Path
@@ -49,5 +50,5 @@ def get_parser() -> argparse.ArgumentParser:
4950
return parser
5051

5152

52-
if __name__ == '__main__':
53+
if __name__ == "__main__":
5354
main()

{{cookiecutter.project_name}}/scripts/setup-remote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Since this is a first time setup script, we intentionally only use builtin Python dependencies.
44
"""
5+
56
import argparse
67
import subprocess
78
from pathlib import Path

{{cookiecutter.project_name}}/scripts/setup-venv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Since this a first time setup script, we intentionally only use builtin Python dependencies.
44
"""
5+
56
import argparse
67
import shutil
78
import subprocess
@@ -22,8 +23,7 @@ def main() -> None:
2223
def get_parser() -> argparse.ArgumentParser:
2324
"""Creates the argument parser for setup-venv."""
2425
parser: argparse.ArgumentParser = argparse.ArgumentParser(
25-
prog="setup-venv",
26-
usage="python ./scripts/setup-venv.py . -p '3.9'"
26+
prog="setup-venv", usage="python ./scripts/setup-venv.py . -p '{{cookiecutter.min_python_version}}'"
2727
)
2828
parser.add_argument(
2929
"path",
@@ -35,7 +35,7 @@ def get_parser() -> argparse.ArgumentParser:
3535
"-p",
3636
"--python",
3737
dest="python_version",
38-
help="The Python version that will serve as the main working version used by the IDE."
38+
help="The Python version that will serve as the main working version used by the IDE.",
3939
)
4040
return parser
4141

@@ -47,7 +47,7 @@ def setup_venv(path: Path, python_version: str) -> None:
4747
["uv", "venv", ".venv"],
4848
["uv", "python", "install", python_version],
4949
["uv", "python", "pin", python_version],
50-
["uv", "sync", "--all-groups"]
50+
["uv", "sync", "--all-groups"],
5151
]
5252
check_dependencies(path=path, dependencies=["uv"])
5353

@@ -59,5 +59,5 @@ def setup_venv(path: Path, python_version: str) -> None:
5959
subprocess.run(command, cwd=path, capture_output=True)
6060

6161

62-
if __name__ == '__main__':
62+
if __name__ == "__main__":
6363
main()

{{cookiecutter.project_name}}/scripts/util.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing util."""
2+
23
import argparse
34
import stat
45
import subprocess
@@ -9,12 +10,17 @@
910

1011
class MissingDependencyError(Exception):
1112
"""Exception raised when a depedency is missing from the system running setup-repo."""
13+
1214
def __init__(self, project: Path, dependency: str):
1315
"""Initializes MisssingDependencyError."""
14-
super().__init__("\n".join([
15-
f"Unable to find {dependency=}.",
16-
f"Please ensure that {dependency} is installed before setting up the repo at {project.absolute()}"
17-
]))
16+
super().__init__(
17+
"\n".join(
18+
[
19+
f"Unable to find {dependency=}.",
20+
f"Please ensure that {dependency} is installed before setting up the repo at {project.absolute()}",
21+
]
22+
)
23+
)
1824

1925

2026
def check_dependencies(path: Path, dependencies: list[str]) -> None:

{{cookiecutter.project_name}}/src/{{cookiecutter.package_name}}/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
app: typer.Typer = typer.Typer()
77

8+
89
@app.command(name="{{cookiecutter.project_name}}")
910
def main() -> None:
1011
"""{{cookiecutter.friendly_name}}."""

0 commit comments

Comments
 (0)