diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 12932b9..f3d2f58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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: [ diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 0be3a6d..7e10f77 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -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") @@ -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, ) diff --git a/pyproject.toml b/pyproject.toml index 833adfa..c810fd6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"]