Python Project

Language: Python October 1, 2025

Instruction file for Python projects with modern best practices.

---
applyTo: "**/*.py"
---

# Python Development Instructions (2025)

_Last updated: October 2025_

- Always use the fetch tool to look up the latest Python best practices and library usage from official documentation: https://docs.python.org
- Use type hints (PEP 484) for all function signatures and class definitions
- Follow PEP 8 style guide for code formatting
- Use modern Python features (3.10+): match statements, structural pattern matching, union types with |
- Prefer dataclasses or Pydantic models for structured data
- Use async/await for I/O-bound operations with asyncio
- Always use virtual environments (venv, poetry, or conda)

**Core Principles:**

- Write idiomatic Python code that follows "The Zen of Python" (PEP 20)
- Use context managers (with statements) for resource management
- Implement proper error handling with specific exception types
- Use list/dict comprehensions and generator expressions appropriately
- Follow the principle of "Explicit is better than implicit"

**Testing:**

- Use pytest for testing with fixtures and parametrize
- Aim for high test coverage with meaningful tests
- Use type checkers (mypy, pyright) for static analysis

**Summary:**

> For all Python work, always use the fetch tool to look up the latest documentation from https://docs.python.org and library-specific docs. Write clean, type-hinted, well-tested code.

Python Backend Programming Language FastAPI Django