Copy of the legacy ~/.pi/agent/docs tree rebuilt as the command-center knowledge base: concept files promoted to path identity, index listings stripped of frontmatter, all wikilinks/relative links resolved, every checkable claim verified against the live fleet (Dankserver = Ryzen 7 7700X + RTX 3090; Strix Halo is Dankclaw), unverifiable claims tagged. kb-lint exits 0.
2.3 KiB
2.3 KiB
type, title, description, tags, timestamp, verified
| type | title | description | tags | timestamp | verified | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| reference | Python | Current best practices for Python projects - uv, pyproject.toml, frameworks, linting, and testing. |
|
2026-08-11 | 2026-08-28 |
CUT
Python
This page covers current (2025/2026) best practices for Python projects.
Package and Project Management
Use uv for new projects. uv replaces pip, pip-tools, pyenv, poetry, and virtualenv. It is much faster than pip and supports workspaces and lockfiles.
Scaffold a project with:
uv init my-project --bare
The command creates a pyproject.toml and a virtual environment. A uv.lock file pins exact dependency versions. Do not edit the lockfile by hand.
Use pyproject.toml as the project manifest. It follows PEP 621. This replaces the older setup.py.
Tooling
| Category | Tool | Notes |
|---|---|---|
| Linter and formatter | Ruff | Replaces Black, isort, flake8, and pylint. |
| Type checker | pyright or mypy | Use pyright in VS Code. Use mypy for strict CI. |
| Testing | pytest | Use pytest-asyncio for async tests. |
| Pre-commit | pre-commit | Run ruff, mypy, and pytest. |
Framework Comparison
| Framework | Best For | Notes |
|---|---|---|
| FastAPI | Modern REST APIs, async | Auto documentation, type-hint validation. |
| Django | Full-stack web apps | Batteries included: ORM, admin, auth. |
| Flask | Lightweight apps | Simpler than FastAPI. |
Use FastAPI for new REST APIs. The recommended workflow is uv run fastapi dev.
Notable 2025/2026 Changes
uvis the dominant project manager.ruffreplaced most separate lint and format tools.pyproject.tomlis the universal manifest.- Python 3.12 gives stability. Python 3.13 adds performance improvements.
Related Technologies
- Uvicorn as the ASGI server.
- SQLAlchemy 2.0 with Alembic for the ORM and migrations.
- httpx for async HTTP clients.
- pydantic-settings for configuration.
- OpenTelemetry for observability.