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
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.flake8",
"ms-python.mypy-type-checker"
"ms-python.mypy-type-checker",
"ms-python.black-formatter"
],
"unwantedRecommendations": []
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"configurations": [
{
"name": "Run current file",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"env": {
Expand Down
2 changes: 1 addition & 1 deletion .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.autopep8"
"editor.defaultFormatter": "ms-python.black-formatter"
},
}
78 changes: 49 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,110 @@
# Changelog

## 0.5.1

- Upgrade all dependencies
- Fix and simplify uv usage in Makefile
- Update vscode setup
- Add a CLAUDE.md

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

## 0.5.0

- Migrated from poetry to uv
- Migrate from poetry to uv

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

## 0.4.2

- Upgraded all dependencies
- Dropped support for Python 3.9
- Upgraded `pyproject.toml` after deprecation
- Upgrade all dependencies
- Drop support for Python 3.9
- Upgrade `pyproject.toml` after deprecation

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

## 0.4.1

- Upgraded all dependencies
- Upgrade all dependencies

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

## 0.4.0

- Added pyproject.toml metadata fields for better <https://pypi.org/> usability
- Upgraded all dependencies
- Add pyproject.toml metadata fields for better <https://pypi.org/> usability
- Upgrade all dependencies

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

## 0.3.4

- Upgraded all dependencies
- Upgrade all dependencies
- Add support and Github actions matrix for Python 3.13
- Dropped support for Python 3.8
- Drop support for Python 3.8

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

## 0.3.3

- Upgraded all dependencies
- Upgrade all dependencies
- Add support and Github actions matrix for Python 3.12

## 0.3.2

- Upgraded all dependencies
- Upgrade all dependencies

## 0.3.1

- Codebase clean-ups

## 0.3.0

- Removed support for Python 3.7
- Upgraded all dependencies
- Added a make target to list outdated dependencies
- Remove support for Python 3.7
- Upgrade all dependencies
- Add a make target to list outdated dependencies

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

## 0.2.0

- Added a script installer for fast CLI access
- Improved readability and infos in README
- Add a script installer for fast CLI access
- Improve readability and infos in README

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

## 0.1.0

- Removed all explicit calls for Python 3 and assuming it everywhere (including project name) [#8](https://github.com/BastiTee/python-boilerplate/pull/8)
- Added a changelog [#9](https://github.com/BastiTee/python-boilerplate/pull/9)
- Remove all explicit calls for Python 3 and assuming it everywhere (including project name) [#8](https://github.com/BastiTee/python-boilerplate/pull/8)
- Add a changelog [#9](https://github.com/BastiTee/python-boilerplate/pull/9)

## 0.0.9

- Added support for Python 3.9-3.11
- Updated dependencies
- Add support for Python 3.9-3.11
- Update dependencies

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

## 0.0.8

- Removed a lot of remaining boilerplate
- Reduced dependencies
- Improved Makefile
- Remove a lot of remaining boilerplate
- Reduce dependencies
- Improve Makefile
- Improve rename script

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

## 0.0.7

- Introduced black code formatting
- Cleaned up README.md
- Introduce black code formatting
- Clean up README.md

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

## 0.0.6

- Migrated from pipenv to poetry
- Introduced matrix testing via Github actions
- Updated configuration files
- Migrate from pipenv to poetry
- Introduce matrix testing via Github actions
- Update configuration files

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

Expand Down Expand Up @@ -123,7 +142,8 @@ First release. Contains support for:
## How to release a new version

- Implement all desired changes on branch
- Update this changelog, bump version number in `pyproject.toml`
- Update this changelog
- Bump version number in `pyproject.toml`
- Finish development on branch and merge to main
- Run

Expand Down
85 changes: 85 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## 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.

## Development Commands

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

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

### Testing
```bash
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
```

### Execution
```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
```

### 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)
```

## 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

### 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")

### Testing
- Uses pytest with `-p no:warnings` to suppress warnings
- Tests should follow the class-based structure in `tests/test_code.py`

### 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
29 changes: 16 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
ifeq (, $(shell which python))
$(error "No python on PATH.")
endif
UV_CMD := python -m uv
ifeq (, $(shell $(UV_CMD) help))
ifeq (, $(shell uv help))
$(error "uv not available in Python installation.")
endif

Expand Down Expand Up @@ -34,51 +33,55 @@ clean:

clear-cache:
@echo Clear dependency cache
$(UV_CMD) cache clean
uv cache clean

venv: clean
@echo Initialize virtualenv, i.e., install required packages etc.
$(UV_CMD) sync
uv sync

# Building software

build: test mypy isort black lint
@echo Run build process to package application
$(UV_CMD) build
uv build

test:
@echo Run all tests suites
$(UV_CMD) run py.test tests
uv run py.test tests

mypy:
@echo Run static code checks against source code base
$(UV_CMD) run mypy $(PY_FILES)
uv run mypy $(PY_FILES)

isort:
@echo Check for incorrectly sorted imports
$(UV_CMD) run isort --check-only $(PY_FILES)
uv run isort --check-only $(PY_FILES)

isort-apply:
@echo Check and correct incorrectly sorted imports
$(UV_CMD) run isort $(PY_FILES)
uv run isort $(PY_FILES)

black:
@echo Run code formatting using black
$(UV_CMD) run black $(PY_FILES)
uv run black $(PY_FILES)

lint:
@echo Run code formatting checks against source code base
$(UV_CMD) run flake8 $(PY_FILES)
uv run flake8 $(PY_FILES)

outdated:
@echo Show outdated dependencies
$(UV_CMD) pip list --outdated
uv pip list --outdated --exclude-editable

update:
@echo Update outdated dependencies
uv sync --upgrade

# Executing

run-venv:
@echo Execute package directly in virtual environment
$(UV_CMD) run python -m my_module
uv run python -m my_module

install-run:
@echo Install and run package via CLI using the activated Python env
Expand Down
Loading