Frontend Labs
⋯

Appendix B — Tooling cheat sheet

# Python and projects (uv)
uv python install 3.14            # install an interpreter
uv init --package app             # new project (src layout)
uv add httpx; uv add --dev pytest # dependencies
uv sync --locked                  # reproducible install
uv run python -m app              # run inside the project env
uv run --with rich python x.py    # one-off extra dependency
uv tool run ruff check .          # run a tool without installing it into the project (alias: uvx)
uv tree; uv lock --upgrade-package httpx

# Quality
ruff check --fix . && ruff format .
mypy --strict src/                # or: pyright
pytest -q -x --lf --pdb           # fast feedback loop
pytest --cov=src --cov-report=term-missing

# Security
pip-audit                         # known-vulnerable dependencies
ruff check --select S .           # bandit rules
python -m pickletools file.pkl    # inspect a pickle before (not) loading it

# Performance and debugging
python -X importtime -c "import pkg"
python -m cProfile -s cumtime app.py
py-spy top --pid PID; py-spy dump --pid PID; py-spy record -o flame.svg -- python app.py
python -X faulthandler app.py
python -m pdb -c continue app.py  # post-mortem on crash
python -m pdb -p PID              # (3.14+) attach to a running process
python -m asyncio ps PID          # (3.14+) list asyncio tasks in a running process
PYTHONASYNCIODEBUG=1 python app.py

# Introspection in the REPL
help(obj); dir(obj); type(obj); vars(obj); obj.__dict__
import inspect; inspect.signature(f); inspect.getsource(f)
import dis; dis.dis(f)
import sys; sys.executable; sys.path; sys.getrefcount(x); sys.getsizeof(x)

Generated from real-life-python-guide.md · 8 Oct 2026 16:36