1.9 KiB
1.9 KiB
name, description, permalink
| name | description | permalink |
|---|---|---|
| python-development | Python ecosystem defaults and workflows using uv for packaging and ruff for linting/formatting | opencode-config/skills/python-development/skill |
Python Development
Load this skill when a repo or lane involves Python code (presence of pyproject.toml, setup.py, requirements*.txt, or .py files as primary source).
Defaults
| Concern | Tool | Notes |
|---|---|---|
| Package/venv management | uv |
Replaces pip, pip-tools, and virtualenv |
| Linting + formatting | ruff |
Replaces flake8, isort, black |
| Test runner | pytest |
Unless repo already uses another runner |
| Type checking | pyright or mypy |
Use whichever the repo already configures |
Core Workflow
- Bootstrap —
uv sync(oruv pip install -e ".[dev]") to create/refresh the venv. - Lint —
ruff check .thenruff format --check .before committing. - Test —
pytestwith the repo's existing config. Follow TDD default policy. - Add dependencies —
uv add <pkg>(runtime) oruv add --dev <pkg>(dev). Do not editpyproject.tomldependency arrays by hand. - Lock —
uv lockafter dependency changes.
Conventions
- Prefer
pyproject.tomloversetup.py/setup.cfgfor new projects. - Keep
ruffconfig inpyproject.tomlunder[tool.ruff]. - Use
uv run <cmd>to execute tools inside the managed venv without activating it. - Pin Python version via
.python-versionorpyproject.tomlrequires-python.
Docker Integration
When the repo runs Python inside Docker, install dependencies with uv pip install inside the container. Mount a named volume for the uv cache to speed up rebuilds.
Red Flags
- Using
pip installdirectly instead ofuv. - Running
blackorisortwhenruffis configured. - Missing
uv.lockafter dependency changes. - Editing dependency arrays in
pyproject.tomlby hand instead of usinguv add.