Prerequisites
Before you begin, make sure you have the following installed:- Python 3.11 or higher — required for all development work
- uv — the recommended package manager for this project
- git — for version control and submitting pull requests
Setting up your environment
Install dev dependencies
Install all dependencies including the Alternatively, using pip:
dev extras:The
dev extras include pytest, ruff, mypy, pre-commit, and type stubs. See pyproject.toml for the full list.Install pre-commit hooks
Set up the pre-commit hooks so linting and formatting run automatically before each commit:The pre-commit configuration runs ruff (lint and format), mypy, and a set of general file checks on every commit.
Project structure
Running tests
Linting and formatting
This project uses ruff for linting and formatting, and mypy for static type checking.Make targets reference
| Target | Description |
|---|---|
make install | Install dependencies with uv |
make test | Run tests with pytest |
make lint | Run ruff and mypy |
make format | Format and auto-fix with ruff |
make check | Run lint then test |
make clean | Remove build artifacts and caches |
make build | Build the package |
Code style guidelines
Import order
Always follow this import grouping order:Always use
from __future__ import annotations as the very first import. Use absolute imports (from archeo_cluster.models import X), and avoid star imports.Type annotations
All functions must have complete type hints:- Use
str | Noneinstead ofOptional[str] - Use
list[str]instead ofList[str](built-in generics) - Use
NDArray[np.uint8]for NumPy arrays - Use Pydantic models for configuration and data transfer
Google-style docstrings
Naming conventions
| Kind | Convention | Example |
|---|---|---|
| Classes | PascalCase | ObjectDetector, DetectionConfig |
| Functions and methods | snake_case | filter_contours, extract_features |
| Variables | snake_case | image_path, cluster_count |
| Constants | UPPER_SNAKE_CASE | CLUSTER_COLORS, SUPPORTED_EXTENSIONS |
| Private members | Single underscore prefix | _save_intermediate_images |
Path handling
Always usepathlib.Path — never string concatenation for file paths:
Logging
Use thelogging module instead of print():
Pull request guidelines
Make your changes
Write clear, atomic commits. Follow Conventional Commits format:
Examples:
| Prefix | Use for |
|---|---|
feat: | New feature |
fix: | Bug fix |
docs: | Documentation changes |
refactor: | Code refactoring (no functional changes) |
test: | Adding or updating tests |
chore: | Maintenance tasks |
Reporting issues
Bug reports
Include your Python version, operating system, package version (
archeo-cluster --version), steps to reproduce, expected vs actual behavior, and any error tracebacks.Feature requests
Describe the use case, your proposed solution if any, and alternatives you have considered.
