diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4dc46e2..ada9b58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ec37131..578ebd9 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 8c0b4a4..9b9a906 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c8e988b..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -cookiecutter