Skip to content

Commit

Permalink
ensure pre-commit working
Browse files Browse the repository at this point in the history
  • Loading branch information
wllgrnt committed May 24, 2024
1 parent bd4b91d commit 2e3c4d4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Loosely based on https://waynerv.github.io/cookiecutter-pypackage/ with only the

## Features
- poetry build system
- pre-commit hooks with flake8, black, and isort formatting
- pre-commit hooks with flake8 and black
- code in a `src` folder
- mkdocs in a `docs` folder (optional)
- pytest in a `tests` folder (optional)
Expand All @@ -28,7 +28,8 @@ The package is installed with `pip install . ` or `poetry install` from the repo

(pyproject.toml doesn't use the newest pyproject.toml syntax or poetry 'with' syntax to maintain pip installability)


Remember to run `pre-commit install` before commiting new code.

### Testing
Run `pytest` from the repo root.

Expand Down
7 changes: 1 addition & 6 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ def remove_file(path):

if include_cli == "n":
remove_file(cli_path)

# install hooks
if os.path.exists(".git"):
subprocess.run(["pip", "install", "pre-commit"])
subprocess.run(["pre-commit", "install"])


# unpack the template into the parent dir
current_dir = os.getcwd()
parent_dir = os.path.dirname(current_dir)
Expand Down
8 changes: 2 additions & 6 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ repos:
- id: end-of-file-fixer
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
"""Tests for `{{ cookiecutter.package_name }}` package."""

import pytest

{% if cookiecutter.include_cli == "y" %}
from click.testing import CliRunner
from {{ cookiecutter.package_name }} import cli
Expand Down

0 comments on commit 2e3c4d4

Please sign in to comment.