Skip to content

Commit 477ec73

Browse files
committed
mention deviations in __post_init__ behaviour
1 parent 670e9c3 commit 477ec73

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/source/structs.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ at the end of the generated ``__init__`` method. It has the same semantics as th
161161
This method may be useful for adding additional logic to the init (such as
162162
custom validation).
163163

164+
.. important::
165+
166+
``__post_init__`` will *not* be called when using any of
167+
168+
- :func:`msgspec.structs.replace`,
169+
- :func:`copy.replace`,
170+
- :func:`copy.copy`,
171+
164172
In addition to in ``__init__``, the ``__post_init__`` hook is also called when:
165173

166174
- Decoding into a struct type (e.g. ``msgspec.json.decode(..., type=MyStruct)``)

0 commit comments

Comments
 (0)