Skip to content

Dataclasses practice problems in Python

Difficulty:
Category:
Tag:

Showing 33 of 33

Status Title Difficulty
Accidental quadratics: an index-backed join and a streaming top-k Medium
A registry that does not prevent collection Medium
asdict() and astuple(): the deep-copy tax Hard
A typed factory fixture Hard
Capstone: an immutable domain model that survives review Hard
Class patterns, __match_args__ and an expression simplifier Medium
ClassVar, field(), and the counter that must reset Easy
Converters and validate-on-assignment: what attrs buys you Medium
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
Does this version satisfy this specifier? Medium
eq, hash, and the eq/frozen/unsafe_hash truth table Hard
field(): the seven knobs that change generated behaviour Medium
frozen=True: what it buys, what it costs, and what it does not do Medium
Generic dataclasses, Self, and the covariance question Hard
Graceful Shutdown of a Process Pool Hard
Guards, OR patterns, AS patterns and the binding rules Medium
heapq: a priority queue that is FIFO among equal priorities Medium
Identity vs equality: fix the planted `is` Easy
kw_only, KW_ONLY and the inheritance ordering wall Medium
order=True, the 3.13 __eq__ change, and orderings that are not tuples Hard
Parse at the boundary, dataclasses in the core Hard
Parse, don't validate: the boundary returns a narrower type Medium
__post_init__ and InitVar: parameters that are consumed, not stored Medium
replace(), copy.replace(), and the mypy gap between them Hard
Runtime introspection after PEP 649: Field.type is not a type Hard
Serializing dataclasses properly: round-trips, paths and schema versions Hard
__slots__, part 2: the eight things it breaks Hard
The configuration boundary in practice: file, environment, argv, one Config Medium
The mutable-default trap — and why the guard is weaker than you think Easy
Typed settings: parse the environment once, report every problem Medium
Writing generic code over dataclasses under --strict Hard