Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .flake8

This file was deleted.

27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
updates:
# Python dependencies (uv/pip ecosystem)
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
commit-message:
prefix: "deps"
groups:
python-dependencies:
patterns:
- "*"

# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
commit-message:
prefix: "ci"
groups:
github-actions:
patterns:
- "*"
25 changes: 13 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ jobs:
matrix:
# https://www.python.org/downloads/
python-version: [
"3.10", # EOL: 2026-10
"3.11", # EOL: 2027-10
"3.12", # EOL: 2028-10
"3.13", # EOL: 2029-10
]
"3.10", # EOL: 2026-10
"3.11", # EOL: 2027-10
"3.12", # EOL: 2028-10
"3.13", # EOL: 2029-10
]
name: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v3
- name: Setup uv
uses: astral-sh/setup-uv@v4
with:
python-version: "${{ matrix.python-version }}"
enable-cache: true

- name: Setup Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: CI checks
run: |
python -m pip install wheel uv
make
run: make
84 changes: 5 additions & 79 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,106 +1,27 @@
Pipfile.lock

# Byte-compiled / optimized / DLL files
*.py[cod]
__pycache__/
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

Expand All @@ -110,3 +31,8 @@ venv.bak/
# Other
.DS_Store

# Ruff linter
.ruff_cache/

# AI tooling
.claude/
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.flake8",
"ms-python.mypy-type-checker",
"ms-python.black-formatter"
"charliermarsh.ruff"
],
"unwantedRecommendations": []
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [],
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 0.6.0

- Simplify .gitignore
- Migrate from black, flake8, and isort to https://github.com/astral-sh/ruff
- Improve CI flow
- Add dependabot config
- Add security scanning
- Add help section to Makefile

[#20](https://github.com/BastiTee/python-boilerplate/pull/20)

## 0.5.1

- Upgrade all dependencies
Expand Down
84 changes: 25 additions & 59 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,82 +4,48 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

This is a Python boilerplate/template project designed as a best-practices starting point for Python modules. It uses `uv` for dependency management and virtual environments (not Poetry or pip-tools). The project name is currently `my_module` and is meant to be renamed via `rename_template.sh` when used as a template.
Python boilerplate/template project using `uv` for dependency management. The project name `my_module` is meant to be renamed via `./rename_template.sh` when used as a template.

## Development Commands

All operations are managed through the Makefile, which acts as a facade for `uv` commands:
All operations are managed through the Makefile (facade for `uv` commands):

### Initial Setup
```bash
make # Clean, create venv, sync dependencies, and run full build
```

### Testing
```bash
make # Full setup: clean, create venv, sync deps, run build
make test # Run pytest test suite
uv run py.test tests # Run all tests
uv run py.test tests/test_code.py # Run a single test file
```

### Code Quality
```bash
make build # Run full build: test, mypy, isort, black, lint, then package
make mypy # Type checking with mypy
make isort # Check import sorting (read-only)
make isort-apply # Fix import sorting
make black # Format code with black
make lint # Run flake8 linting
make build # Run test, mypy, lint, format, then package
make mypy # Type checking
make lint # Ruff linting
make lint-fix # Auto-fix lint issues
make format # Format code with ruff
make run-venv # Run module: uv run python -m my_module
```

### Execution
### Running Single Tests
```bash
make run-venv # Run the module directly: uv run python -m my_module
make install-run # Install package and run via CLI as my_module_cli
uv run py.test tests/test_code.py # Single file
uv run py.test tests/test_code.py::TestCode # Single class
uv run py.test tests/test_code.py -k "test_code" # By name pattern
```

### Environment Management
```bash
make clean # Remove all generated files (.venv, caches, build artifacts)
make venv # Clean and recreate virtual environment with uv sync
make clear-cache # Clear uv dependency cache
make outdated # Show outdated dependencies
make update # Update outdated dependencies
```

### Template Setup
```bash
./rename_template.sh # Rename the template project (interactive script)
make clean # Remove .venv, caches, build artifacts
make venv # Recreate virtual environment
make update # Update dependencies
```

## Architecture

### Package Structure
- `my_module/` - Main module code
- `__init__.py` - Package initialization
- `__main__.py` - Entry point with `main()` function
- `tests/` - Test suite using pytest
- CLI entry point defined in pyproject.toml as `my_module_cli`

### Build System
- Uses `uv` as the build backend (specified in pyproject.toml)
- `module-root = ""` in uv build config means the package is at repository root
- Package structure follows packaging.python.org standards
- `my_module/` - Main package with `__main__.py` entry point
- `tests/` - pytest test suite (class-based structure)
- CLI entry point: `my_module_cli` (defined in pyproject.toml)

### Code Quality Configuration
- **Black**: Line length 88, `skip-string-normalization = true`
- **Flake8**: Max line length 88 (matches black), ignores Q003, W503, E203
- **Mypy**: Strict mode with `disallow_untyped_defs = true`, `check_untyped_defs = true`
- **isort**: Configured to work with black and flake8
- Python versions supported: 3.10, 3.11, 3.12, 3.13 (requires-python: ">=3.10,<3.14")
## Code Quality

### Testing
- Uses pytest with `-p no:warnings` to suppress warnings
- Tests should follow the class-based structure in `tests/test_code.py`
- **Ruff**: Linting + formatting (line-length 88, quote-style preserve)
- Includes security scanning via flake8-bandit (S) rules
- **Mypy**: Strict mode (`disallow_untyped_defs = true`)
- **Python**: 3.10, 3.11, 3.12, 3.13

### VSCode Integration
- Python formatter: black-formatter (format on save enabled)
- Pytest discovery enabled
- Tab size: 4 spaces
- Word wrap: 88 columns
- Trailing whitespace automatically trimmed
All config is centralized in `pyproject.toml`.
Loading
Loading