Skip to content

Commit 61dde01

Browse files
committed
chore: turn repo into Cookiecutter template with pre-commit wiring and templated files
1 parent 81cc2f2 commit 61dde01

File tree

9 files changed

+138
-5069
lines changed

9 files changed

+138
-5069
lines changed

.pre-commit-config.yaml

Whitespace-only changes.

README.md

Lines changed: 34 additions & 5049 deletions
Large diffs are not rendered by default.

cookiecutter.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"author_name": "Your Name",
55
"author_email": "[email protected]",
66
"description": "A short description of the project",
7-
"python_version": "3.11"
7+
"python_version": "3.11",
8+
"pre_commit_hooks_rev": "v5.0.0",
9+
"ruff_pre_commit_rev": "v0.11.9",
10+
"mypy_rev": "v1.15.0",
11+
"bandit_rev": "1.8.3",
12+
"commitizen_rev": "v4.7.0",
13+
"docformatter_rev": "v1.7.7"
814
}

pyproject.toml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
# Core development tools
2-
pip install \
3-
ruff \
4-
mypy \
5-
pytest pytest-cov pytest-asyncio \
6-
pre-commit \
7-
pip-tools \
8-
commitizen
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
94

10-
# Additional utilities (optional but recommended)
11-
pip install \
12-
bandit \
13-
safety \
14-
prettier \
15-
autopep8 \
16-
docformatter \
17-
types-requests types-setuptools
5+
[project]
6+
name = "{{ cookiecutter.project_slug }}"
7+
version = "0.1.0"
8+
description = "{{ cookiecutter.description }}"
9+
authors = [{ name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.author_email }}" }]
10+
readme = "README.md"
11+
requires-python = ">= {{ cookiecutter.python_version }}"
12+
dependencies = [
13+
# Add your project dependencies here
14+
]
15+
16+
[project.optional-dependencies]
17+
dev = [
18+
"pre-commit>=4.4.0", # Git hooks manager
19+
"ruff>=0.11.9", # Linter/formatter
20+
"mypy>=1.15.0", # Static type checker
21+
"bandit>=1.8.3", # Security linter
22+
"docformatter>=1.7.7",# Docstring formatter
23+
"commitizen>=4.7.0" # Conventional commits
24+
]

src/{{cookiecutter.project_slug}}/__init__.py

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
Core functionality for {{ cookiecutter.project_name }}.
3+
"""
4+
5+
def greet(name: str) -> str:
6+
"""Return a greeting for the given name."""
7+
return f"Hello, {name}!"
8+
9+
if __name__ == "__main__":
10+
# Example entry point
11+
print(greet("World"))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Command-line interface for {{ cookiecutter.project_name }} using Typer.
3+
"""
4+
import typer
5+
from {{ cookiecutter.project_slug }}.main import greet
6+
7+
app = typer.Typer()
8+
9+
@app.command()
10+
def hello(name: str):
11+
"""Greet someone by name."""
12+
typer.echo(greet(name))
13+
14+
15+
if __name__ == "__main__":
16+
app()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from rich import print
2+
from rich.panel import Panel
3+
from rich.table import Table
4+
5+
# Project metadata
6+
my_dict = {
7+
"project_name": "{{ cookiecutter.project_name }}",
8+
"project_slug": "{{ cookiecutter.project_slug }}",
9+
"author": "{{ cookiecutter.author_name }}",
10+
"description": "{{ cookiecutter.description }}",
11+
"python_version": "{{ cookiecutter.python_version }}"
12+
}
13+
14+
# Sample data
15+
my_list = [1, "apple", {"key": "value"}, True, None, 3.14]
16+
17+
print("--- Rich Printing ---")
18+
print(my_dict)
19+
print(my_list)
20+
21+
# Welcome panel
22+
print(Panel(
23+
f"Hello, [bold magenta]{{ cookiecutter.project_name }}[/]!",
24+
title="[bold green]Welcome to {{ cookiecutter.project_name }}[/]",
25+
subtitle="Generated by Cookiecutter"
26+
))
27+
28+
# Task overview table
29+
table = Table(title="{{ cookiecutter.project_name }} Task Overview")
30+
31+
table.add_column("ID", style="dim", width=6)
32+
table.add_column("Task Name")
33+
table.add_column("Status", justify="right")
34+
35+
table.add_row("1", "Initialize Repository", "[green]Done[/]")
36+
table.add_row("2", "Configure Pre-commit Hooks", "[yellow]In Progress[/]")
37+
table.add_row("3", "Start Development", "[red]Pending[/]")
38+
39+
print(table)

tests/test_main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# tests/test_main.py
2-
from src.my_package.main import greet
1+
"""
2+
Test suite for the greeting functionality.
3+
"""
4+
import pytest
5+
from {{ cookiecutter.project_slug }}.main import greet
6+
37

48
def test_greet():
5-
assert greet("Developer") == "Hello, Developer"
9+
"""Ensure greet returns the expected string with an exclamation."""
10+
assert greet("Developer") == "Hello, Developer!"

0 commit comments

Comments
 (0)