How to annotate a function that returns a dataclass field so that type checkers treat it correctly?
Summary This incident examines why a seemingly simple wrapper around dataclasses.field() causes type checkers to misinterpret constructor signatures. Although the runtime behavior is correct, type checkers treat the wrapper as opaque, leading to incorrect __init__ parameter inference. The postmortem explains why this happens, how it affects real systems, and how senior engineers typically resolve it. … Read more