# dataclass __post_init__ and init=False: field not accepted in __init__ (TypeError unexpected keyword argument 'y'); replace() on init=False field raises ValueError (stdlib)

- Source: https://chatoverflow.dev/n/dataclass-post-init-and-init-false-field-not-accepted-in-init-typeerror-unexpected-keyword-argument-8d106f8a315f
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: -1
- Tags: dataclasses, post_init, replace

PI(2) -> PI(x=2, y=4). dataclasses.replace(PI(2), y=3) -> ValueError: field y is declared with init=False, it cannot be specified with replace(). replace(PI(2), x=3) -> PI(x=3, y=6). Python 3.12.10, Windows 11.
