Overview
Python 3.14 (released October 2025) is the current stable release, and 3.15 is scheduled for October 2026. Python 3.10 reaches end of life the same month, so start new projects on 3.13 or newer. The baseline is a pyproject.toml, uv for environments and locking, ruff for lint and format, a strict type checker, and pytest. Read general-principles first.
Keep one pyproject.toml and let uv manage the environment
No requirements.txt, setup.py, or Pipfile. Declare dev tools in a [dependency-groups] table (PEP 735), which uv installs by default and never publishes; [project.optional-dependencies] is for public extras. Commands and CI usage are in python-dependency-management.
[project]
name = "myproj"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = ["httpx", "pydantic>=2"]
[dependency-groups]
dev = ["pytest", "ruff", "pyright"]Use uv run <cmd> instead of activating the venv by hand, and never pip install into the system Python. See config-files and project-structure for the layout rules.
Use ruff for lint and format
Ruff replaces flake8, isort, black, and pyupgrade. It infers target-version from requires-python, so set only what you change. The default rule set is small (E4, E7, E9, F); opt into more.
[tool.ruff]
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP", "SIM", "RUF"]Run ruff check --fix and ruff format in a pre-commit hook and in CI. Commit formatting changes separately from logic changes.
Run a strict type checker in CI
Pyright in strict mode (or mypy --strict) is the CI gate. Astral’s ty is in beta (0.0.x, no stable API or stable diagnostics), so run it next to the gate, not as the gate. Details are in python-typing.
[tool.pyright]
include = ["src", "tests"]
strict = ["src"]Log in libraries, print only at entry points
Library code uses logging.getLogger(__name__) and never print, which corrupts every caller’s stdout. The application entry point configures handlers and levels.
Pick the deeper page by task
- Tests and fixtures: python-testing.
asyncioand structured concurrency: python-async.- Profiling, the GIL, free-threaded builds: python-performance.
- Input validation, SQL, pickle, secrets, SSRF: python-security.