Skip to content

Commit

Permalink
✨ Update cookiecutter to match cookiecutter-python-cli-app further
Browse files Browse the repository at this point in the history
  • Loading branch information
sgraaf committed Dec 26, 2023
1 parent 1ba73d9 commit 8b5d8eb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 46 deletions.
17 changes: 7 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,25 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-json
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: 0.27.3
hooks:
- id: check-dependabot
- id: check-github-workflows
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.9
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- --show-fixes
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
rev: v3.1.0
hooks:
- id: prettier
54 changes: 32 additions & 22 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,52 @@ def possibly_install_pipx() -> None:
subprocess.run([sys.executable, "-m", "pipx", "ensurepath"], check=False)


# possibly install nox (and pipx)
if shutil.which("nox") is None:
# possibly install pipx
possibly_install_pipx()

# install nox
subprocess.run([sys.executable, "-m", "pipx", "install", "nox"], check=False)

# possibly install pre-commit (and pipx)
if shutil.which("pre-commit") is None:
# possibly install pipx
possibly_install_pipx()

# install pre-commit
subprocess.run([sys.executable, "-m", "pipx", "install", "pre-commit"], check=False)

# perform git initialization
if "{{ cookiecutter.init_git }}" == "True":
# initialize Git repository
subprocess.run(["git", "init", "-b", "main"], check=False)

# possibly install pre-commit (and pipx)
if shutil.which("pre-commit") is None:
# possibly install pipx
possibly_install_pipx()

# install pre-commit
subprocess.run(
[sys.executable, "-m", "pipx", "install", "pre-commit"], check=False
)

# install and update pre-commit hooks
subprocess.run(["pre-commit", "install"], check=False)
# update and install pre-commit hooks
subprocess.run(["pre-commit", "autoupdate"], check=False)
subprocess.run(["pre-commit", "install", "--install-hooks"], check=False)

# add and commit
# add files
subprocess.run(["git", "add", "."], check=False)

# run nox "cog" and "pre_commit" sessions
subprocess.run(["nox", "--session", "cog", "pre_commit"], check=False)

# possibly re-add files
subprocess.run(["git", "add", "."], check=False)

# commit
subprocess.run(
["git", "commit", "-m", "🍪 Initial commit from `cookiecutter-python-package`"],
[
"git",
"commit",
"-m",
":cookie: Initial commit from `cookiecutter-python-package`",
],
check=False,
)

# create venv and install dependencies
if "{{ cookiecutter.init_venv }}" == "True":
# possibly install nox (and pipx)
if shutil.which("nox") is None:
# possibly install pipx
possibly_install_pipx()

# install nox
subprocess.run([sys.executable, "-m", "pipx", "install", "nox"], check=False)

# run nox "dev" session
subprocess.run(["nox", "--session", "dev"], check=False)
16 changes: 3 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ ignore = [
"E501", # line too long, handled by black
"COM", # flake8-commas, handled by black
"CPY", # flake8-copyright
"ISC001", # single-line-implicit-string-concatenation
"INP", # flake8-no-pep420
]
src = ["src", "tests", "docs"]
target-version = "py38" # the minimum Python version supported, used by pyupgrade

[tool.ruff.per-file-ignores]
"hooks/*.py" = [
"D", # pydocstyle
"PLR0133", # comparison-of-constant
"S603", # subprocess-without-shell-equals-true
"S607", # start-process-with-partial-path
]

[tool.ruff.isort]
known-first-party = [
"{{ cookiecutter.project_name }}",
"tests",
]
lines-between-types = 0
src = ["hooks"]
target-version = "py38" # the minimum Python version supported, used by pyupgrade
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

1 comment on commit 8b5d8eb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.