Skip to content

Typing practice problems in Python

Difficulty:
Category:
Tag:

Showing 50 of 130

Status Title Difficulty
abc.ABC: abstract properties and classmethods, in the right order Easy
Accept broad, return narrow: group_by and merge_counts Medium
A Fetcher Protocol three implementations can satisfy Medium
A @final rate limiter Easy
A generic Result[T, E] Medium
Amortise cents without mixing up the units Medium
Annotated: metadata the type checker deliberately ignores Medium
A rate limiter you can test without sleeping Hard
A recursive Json alias, depth and flatten Medium
A registry that does not prevent collection Medium
asdict() and astuple(): the deep-copy tax Hard
assert_never and the event that was never handled Medium
Async iterators: the paginator you can actually close Medium
A typed factory fixture Hard
Auditing a library for import-time side effects Hard
Auditing the Any surface of a module Medium
Bare except, blind except Exception, and where to catch Medium
Batched async stream: never yield inside a cancel scope Hard
BoundedCounter: check-then-act under 64 threads Medium
Bounds versus constraints: clamp and dedupe Hard
cache: memoised edit distance behind a validated wrapper Medium
Callback protocols: closing the Callable[..., Any] hole Medium
Capstone: the upload that cannot be misused Hard
ChainMap: resolve config and keep the provenance Medium
ClassVar, field(), and the counter that must reset Easy
Coerce to int at an untyped boundary Medium
contextmanager: temporarily patch an attribute, and put it back Medium
Counter: top n-grams with deterministic ties Easy
Dataclasses: slots, frozen, order Easy
@dataclass is a code generator: what it emits Easy
dataclass_transform (PEP 681): making your own decorator type-checkable Hard
defaultdict: group rows, hand back a plain dict Easy
Deprecating public API: @warnings.deprecated Medium
deque: rolling median and the maxlen narrowing Medium
Does this version satisfy this specifier? Medium
Every import cycle, deterministically Hard
Exception chaining: raise ... from Medium
ExceptionGroup, split() and except* Hard
Exception hierarchies as API design Medium
Exhaustive matching with assert_never Hard
Failure aggregation over batches Medium
Flag: a permission mask that prints, iterates and refuses bad bits Medium
Flatten a union at runtime Easy
Flattening a dependency group Medium
Forbidden import chains, with the route Hard
Generic dataclasses, Self, and the covariance question Hard
Generic partition and chunk Medium
groupby: summarise rows without losing half of them Medium
heapq: a priority queue that is FIFO among equal priorities Medium
hot_functions: the column you sort by is the answer you get Medium