( NOTES · 002 )
Python Notes
good to use libs, for things I commonly do.
- typer - cli
- fastapi + sqlalchemy + sqlmodel - BE Service + DB thing, sqlmodel allows bridging SQLAlchemy and Pydantic
- pydantic + pydantic-settings - pydantic for validation and pydantic-settings for config stuff
- openpyxl - excel sheets, avoid pandas if you don’t need the additional stuff.
- paramiko + fabric - SSH client, pure python
- rich - nice logs and console stuff. use Console() and work from there.
- httpx2 - HTTP client, sync + async behind one API. Not
httpx, that stopped at v0.28.1 in Dec 2024 and the tracker closed Feb 2026. Pydantic Services took it over with the original author, drop-in for common use. Starlette moved in May 2026. - psycopg (v3) - postgres.
psycopg[binary]in images, bundles libpq. - dateparser - messy human dates, many languages. “last Tuesday”, “vor 3 Tagen”. Right tool when the source picks a different format every document.
- whenever - dateparser makes datetimes out of strings, whenever replaces stdlib
datetimewith DST-correct arithmetic and separate aware/plain types. Parse with one, compute with the other. - alembic - migrations, works even when the app cannot run DDL.
alembic revision --autogenerateagainst a throwaway DB, thenalembic upgrade head --sql > ddl.sql. Models stay source of truth, platform team gets reviewable DDL. Autogenerate still needs some DB to diff against. - tenacity - retries with backoff and jitter. Worth it against flaky enterprise services and LLM APIs.
- structlog - only if logs go to an aggregator. Pipeline, not a renderer, composes with rich rather than replacing it. Pretty on a TTY, JSON lines otherwise. Rich boxes are hostile inside Loki.
- polars - dataframes. Only if you were about to reach for pandas. Reading a spreadsheet is still openpyxl.
- pytest + pytest-cov + pytest-asyncio + ruff - test and lint base. Nothing in it type-checks.
--cov-fail-underin CI or coverage is a number nobody reads. - mypy or pyright - the gap in 15.
- testcontainers - real postgres instead of sqlite-that-lies. Matters once psycopg and SQLAlchemy are involved.
- hypothesis - property based. Good for parsing, validation, extraction.
- time-machine - freeze time, faster than freezegun.
- pytest-randomly - finds tests that secretly depend on each other.
- pytest-mock, pytest-xdist, pre-commit.