Skip to main content

Useful type hints for Python

  • Posted

A collection of non-obvious type hints that I couldn’t easily find in documentation or Google searches.

I type check most of my Python code with mypy --strict. This note describes some of the non-obvious type hints that I couldn’t easily find in documentation or Google searches.

pytest parameterised tests

import pytest
from _pytest.mark.structures import ParameterSet

params: list[ParameterSet] = [
    pytest.param("1", id="one"),
    pytest.param("2", id="two"),
    pytest.param("3", id="three"),
]