Skip to content

Commit 13a2bc5

Browse files
committed
Docs
1 parent e4ad03f commit 13a2bc5

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

HISTORY.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ Our backwards-compatibility policy can be found [here](https://github.com/python
2323
and {func}`cattrs.gen.typeddicts.make_dict_structure_fn` will use the value for the `use_alias` parameter from the given converter by default now.
2424
If you're using these functions directly, the old behavior can be restored by passing in the desired value directly.
2525
([#596](https://github.com/python-attrs/cattrs/issues/596) [#660](https://github.com/python-attrs/cattrs/pull/660))
26+
- The union passthrough strategy now by default accepts ints for unions that contain floats but not ints,
27+
when configured to be able to handle both ints and floats.
28+
This more closely matches the [current typing behavior](https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex).
29+
([#656](https://github.com/python-attrs/cattrs/issues/656) [#668](https://github.com/python-attrs/cattrs/pull/668))
2630
- Fix unstructuring of generic classes with stringified annotations.
2731
([#661](https://github.com/python-attrs/cattrs/issues/661) [#662](https://github.com/python-attrs/cattrs/issues/662)
28-
- For {class}`cattrs.errors.StructureHandlerNotFoundError` and {class}`cattrs.errors.ForbiddenExtraKeysError`
29-
correctly set {attr}`BaseException.args` in `super()` and hence make them pickable.
32+
- For {class}`cattrs.errors.StructureHandlerNotFoundError` and {class}`cattrs.errors.ForbiddenExtraKeysError`
33+
correctly set {attr}`BaseException.args` in `super()` and hence make them pickable.
3034
([#666](https://github.com/python-attrs/cattrs/pull/666))
3135

3236
## 25.1.1 (2025-06-04)

src/cattrs/strategies/_unions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,14 @@ def configure_union_passthrough(
164164
If the union contains a class and one or more of its subclasses, the subclasses
165165
will also be included when validating the superclass.
166166
167+
:param accept_ints_as_floats: When set (the default), if the provided union
168+
contains both ints and floats, actual unions containing only floats will also accept
169+
ints. See https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex
170+
for more information.
171+
167172
.. versionadded:: 23.2.0
173+
.. versionchanged:: 25.2.0
174+
Introduced the `accept_ints_as_floats` parameter.
168175
"""
169176
args = set(union.__args__)
170177

0 commit comments

Comments
 (0)