typing.Protocol in Python: Structural Typing
Define lightweight contracts with typing.Protocol and accept compatible objects without requiring explicit inheritance.
Explore our technical articles, practical tutorials, and career guides.
The fuel for your journey in the Python Universe.
Define lightweight contracts with typing.Protocol and accept compatible objects without requiring explicit inheritance.
Coordinate related tasks with asyncio.TaskGroup while understanding results, failures, cancellation, and gather.
Organize shared API logic with FastAPI Depends, Annotated, sub-dependencies, yield, and test overrides.
Build clearer tests with fixtures, temporary files, and monkeypatch without testing mocks instead of behavior.
Turn a DataFrame into an interactive Streamlit dashboard with filters, metrics, charts, and deliberate caching.
Version schema changes with Alembic and SQLAlchemy, reviewing generated migrations before applying them safely.
Use Ruff for linting, import sorting, and formatting with a small configuration and predictable CI checks.
Set up a Python project with uv, a virtual environment, pyproject.toml, and a reproducible lockfile while understanding what changes from pip.
Build lean Python documentation with Sphinx, autodoc, docstrings, and type hints, then generate HTML and automate publishing without needless complexity.
Use Hypothesis with pytest to generate inputs, check invariants, shrink failures, and uncover edge cases that hand-written examples miss.
Structure pyproject.toml for applications and libraries, separate build and runtime requirements, declare dependencies, and configure tools safely.
A practical Python Playwright guide covering browser setup, robust locators, state-based waits, downloads, screenshots, pytest, and responsible use.