You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The `omit` parameter of {py:func}`cattrs.override` is now of type `bool | None` (from `bool`).
20
20
`None` is the new default and means to apply default _cattrs_ handling to the attribute, which is to omit the attribute if it's marked as `init=False`, and keep it otherwise.
21
+
- Converters can now be initialized with custom fallback hook factories for un/structuring.
- Fix {py:func}`format_exception() <cattrs.v.format_exception>` parameter working for recursive calls to {py:func}`transform_error <cattrs.transform_error>`.
-[_attrs_ aliases](https://www.attrs.org/en/stable/init.html#private-attributes-and-aliases) are now supported, although aliased fields still map to their attribute name instead of their alias by default when un/structuring.
`Converter._structure_func.dispatch` and `Converter._unstructure_func.dispatch` are slated to become public APIs in a future release.
69
+
```
70
+
71
+
```{versionadded} 23.2.0
72
+
73
+
```
74
+
38
75
## `cattrs.Converter`
39
76
40
-
The {class}`Converter <cattrs.Converter>` is a converter variant that automatically generates,
41
-
compiles and caches specialized structuring and unstructuring hooks for _attrs_
42
-
classes and dataclasses.
77
+
The {class}`Converter <cattrs.Converter>` is a converter variant that automatically generates, compiles and caches specialized structuring and unstructuring hooks for _attrs_ classes, dataclasses and TypedDicts.
43
78
44
79
`Converter` differs from the {class}`cattrs.BaseConverter` in the following ways:
45
80
@@ -53,7 +88,5 @@ The `Converter` used to be called `GenConverter`, and that alias is still presen
53
88
54
89
## `cattrs.BaseConverter`
55
90
56
-
The {class}`BaseConverter <cattrs.BaseConverter>` is a simpler and slower Converter variant. It does no
57
-
code generation, so it may be faster on first-use which can be useful
58
-
in specific cases, like CLI applications where startup time is more
59
-
important than throughput.
91
+
The {class}`BaseConverter <cattrs.BaseConverter>` is a simpler and slower `Converter` variant.
92
+
It does no code generation, so it may be faster on first-use which can be useful in specific cases, like CLI applications where startup time is more important than throughput.
Copy file name to clipboardExpand all lines: docs/customizing.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This section deals with customizing the unstructuring and structuring processes
6
6
7
7
The default {class}`Converter <cattrs.Converter>`, upon first encountering an _attrs_ class, will use the generation functions mentioned here to generate the specialized hooks for it, register the hooks and use them.
8
8
9
-
## Manual un/structuring hooks
9
+
## Manual Un/structuring Hooks
10
10
11
11
You can write your own structuring and unstructuring functions and register
12
12
them for types using {meth}`Converter.register_structure_hook() <cattrs.BaseConverter.register_structure_hook>` and
0 commit comments