Skip to content

Commit 77f3c75

Browse files
authored
docs/defaulthooks: add note on TypedDict Required/NotRequired with from __future__ import annotations (#620)
Fix #619.
1 parent f4a7385 commit 77f3c75

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/defaulthooks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ Generic TypedDicts work on Python 3.11 and later, since that is the first Python
333333

334334
[`typing.Required` and `typing.NotRequired`](https://peps.python.org/pep-0655/) are supported.
335335

336+
:::{caution}
337+
If `from __future__ import annotations` is used or if annotations are given as strings, `Required` and `NotRequired` are ignored by cattrs.
338+
See [note in the Python documentation](https://docs.python.org/3/library/typing.html#typing.TypedDict.__optional_keys__).
339+
:::
340+
336341
[Similar to _attrs_ classes](customizing.md#using-cattrsgen-hook-factories), un/structuring can be customized using {meth}`cattrs.gen.typeddicts.make_dict_structure_fn` and {meth}`cattrs.gen.typeddicts.make_dict_unstructure_fn`.
337342

338343
```{doctest}

0 commit comments

Comments
 (0)