Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,14 @@ repos:
{{cookiecutter.package_name}}/setup.cfg
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.7
rev: v0.15.9
hooks:
- id: ruff
- id: ruff-check
args: [--fix, hooks, tests]
pass_filenames: false
- id: ruff-format
args: [hooks, tests]
pass_filenames: false
- repo: https://github.com/dosisod/refurb
rev: v2.3.0
hooks:
- id: refurb
args: [--ignore, FURB126]
exclude: ({{cookiecutter.package_name}})
- repo: https://github.com/econchick/interrogate
rev: 1.7.0
hooks:
Expand Down Expand Up @@ -86,7 +80,7 @@ repos:
additional_dependencies: [tomli]
exclude: (^|/)uv\.lock$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.19.1'
rev: 'v1.20.0'
hooks:
- id: mypy
args: [
Expand Down
15 changes: 10 additions & 5 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def remove_directory(*filepath: str | Path) -> None:
def main() -> None:
"""Apply post generation hooks."""
project_path = Path.cwd()
git = shutil.which("git")

if git is None:
msg = "Could not find 'git' on PATH."
raise RuntimeError(msg)

if "{{ cookiecutter.open_source_license }}" == "Not open source":
remove_file(project_path, "LICENSE")
Expand All @@ -35,22 +40,22 @@ def main() -> None:
remove_file(project_path, ".readthedocs.yaml")

subprocess.run(
("git", "init", "--initial-branch", "main"), check=True, capture_output=True
(git, "init", "--initial-branch", "main"), check=True, capture_output=True
)

if "{{ cookiecutter.make_initial_commit }}" == "yes":
# Create an initial commit on the main branch and restore global default name.
subprocess.run(
("git", "config", "user.name", "'{{ cookiecutter.github_username }}'"),
(git, "config", "user.name", "'{{ cookiecutter.github_username }}'"),
check=True,
)
subprocess.run(
("git", "config", "user.email", "'{{ cookiecutter.github_email }}'"),
(git, "config", "user.email", "'{{ cookiecutter.github_email }}'"),
check=True,
)
subprocess.run(("git", "add", "."), check=True)
subprocess.run((git, "add", "."), check=True)
subprocess.run(
("git", "commit", "-m", "'Initial commit.'"),
(git, "commit", "-m", "'Initial commit.'"),
check=True,
capture_output=True,
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extend-ignore = [
]

[tool.ruff.lint.per-file-ignores]
"hooks/post_gen_project.py" = ["PLR0133"]
"hooks/post_gen_project.py" = ["PLR0133", "S603"]
"hooks/*" = ["INP001"]
"tests/*" = ["D", "ANN"]

Expand Down
Loading