|
| 1 | +# Copilot Instructions for Python Development |
| 2 | + |
| 3 | +This project uses a modern, high-performance Python toolchain. Please adhere to the following guidelines and tool usages when generating code or commands. |
| 4 | + |
| 5 | +## Toolchain & Workflow |
| 6 | + |
| 7 | +### Dependency & Project Management: `uv` |
| 8 | +- **Primary Tool**: Use `uv` for all project management tasks. |
| 9 | +- **Overview**: `uv` is an extremely fast Python package and project manager written in Rust. It effectively replaces `pip`, `poetry`, and `pip-tools`. |
| 10 | +- **Commands**: |
| 11 | + - Add dependencies: `uv add <package>` |
| 12 | + - Add dev dependencies: `uv add --dev <package>` |
| 13 | + - Run scripts: `uv run <script.py>` or `uv run -m <module>` |
| 14 | + - Sync environment: `uv sync` (creates/updates `.venv`) |
| 15 | + - Lock dependencies: `uv lock` |
| 16 | +- **Configuration**: Managed in `pyproject.toml`. |
| 17 | + |
| 18 | +### Linting & Formatting: `ruff` |
| 19 | +- **Linter & Formatter**: Use `ruff` for all linting and formatting. |
| 20 | +- **Overview**: `ruff` is an extremely fast Python linter and code formatter written in Rust. It replaces tools like Black, Flake8, and isort. |
| 21 | +- **Commands**: |
| 22 | + - Check: `uvx ruff check` (fix with `--fix`) |
| 23 | + - Format: `uvx ruff format` |
| 24 | +- **Style**: Code should be compliant with `ruff`'s default rules and any overrides in `pyproject.toml` or `ruff.toml`. |
| 25 | + |
| 26 | +### Type Checking: `ty` |
| 27 | +- **Type Checker**: Use `ty` for static type checking. |
| 28 | +- **Overview**: `ty` is a fast Python type checker and language server found in the Astral ecosystem. |
| 29 | +- **Commands**: |
| 30 | + - Check: `uvx ty check` |
| 31 | +- **Typing**: Ensure all code is fully typed. Use modern Python type hinting features. |
| 32 | + |
| 33 | +### Task Management: `just` |
| 34 | +- **Task Runner**: Uses `just` to run project-specific tasks. |
| 35 | +- **Overview**: `just` is a handy command runner that saves and runs project-specific commands (recipes) stored in a `Justfile`. |
| 36 | +- **Usage**: Check the `Justfile` (if present) for available recipes. |
| 37 | +- **Recommendation**: If users ask to run common tasks (build, test, lint), check if a `just` recipe exists. |
| 38 | +- **installation**: `just` can be installed via package managers like `brew`, `apt`, or using uv: |
| 39 | + ```bash |
| 40 | + uv tool install rust-just |
| 41 | + ``` |
| 42 | + |
| 43 | +### Git Hooks: `pre-commit` |
| 44 | +- **Automation**: `pre-commit` ensures code quality before committing. |
| 45 | +- **Overview**: Framework for managing and maintaining multi-language pre-commit hooks. |
| 46 | +- **Commands**: |
| 47 | + - Run manually: `uvx pre-commit run --all-files` |
| 48 | +- **installation**: |
| 49 | + ```bash |
| 50 | + uv tool install pre-commit |
| 51 | + pre-commit install |
| 52 | + ``` |
| 53 | + |
| 54 | +### Build System: `hatchling` |
| 55 | +- **Backend**: The project uses `hatchling` as the build backend. |
| 56 | +- **Overview**: `hatchling` is a modern, extensible build backend for Python projects. |
| 57 | +- **Configuration**: Build settings are defined in the `[build-system]` section of `pyproject.toml`. |
| 58 | + |
| 59 | +### Testing: `pytest` |
| 60 | +- **Framework**: Use `pytest` for testing. |
| 61 | +- **Overview**: The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing. |
| 62 | +- **Commands**: |
| 63 | + - Run tests: `uv run pytest` |
| 64 | +- **Practices**: Write unit tests for new functionality in the `tests/` directory. |
| 65 | + |
| 66 | +## Commit Messages |
| 67 | + |
| 68 | +- **Strict Requirement**: You **MUST** reference and follow the commit message conventions defined in `.copilot-commit-message-instructions.md` located in the project root. |
| 69 | +- All generated commit messages should adhere to the format and rules specified in that file. |
| 70 | + |
| 71 | +## General Development Guidelines |
| 72 | + |
| 73 | +- **Modern Python**: Use modern Python features (3.10+). |
| 74 | +- **Type Safety**: Prioritize type safety and clarity. |
| 75 | +- **Performance**: Leverage the speed of the provided Rust-based tools (`uv`, `ruff`, `ty`). |
0 commit comments