Skip to content

Commit 2c7591c

Browse files
committed
Docs and test
1 parent ed27192 commit 2c7591c

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Our backwards-compatibility policy can be found [here](https://github.com/python
3232
- For {class}`cattrs.errors.StructureHandlerNotFoundError` and {class}`cattrs.errors.ForbiddenExtraKeysError`
3333
correctly set {attr}`BaseException.args` in `super()` and hence make them pickable.
3434
([#666](https://github.com/python-attrs/cattrs/pull/666))
35+
- The default disambiguation hook factory is now only enabled for converters with `unstructure_strat=AS_DICT` (the default).
36+
Since the strategy doesn't support tuples, it is skipped for `unstructure_strat=AS_TUPLE` converters.
37+
([#673](https://github.com/python-attrs/cattrs/pull/673))
3538

3639
## 25.1.1 (2025-06-04)
3740

tests/test_disambiguators.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,30 @@ class L:
113113
fn([])
114114

115115

116+
def test_input_not_mapping():
117+
"""Correct errors are raised when the raw payload isn't a mapping."""
118+
c = Converter()
119+
120+
@define
121+
class A:
122+
a: int
123+
124+
@define
125+
class B:
126+
b: int
127+
128+
@define
129+
class C:
130+
pass
131+
132+
with pytest.raises(ValueError):
133+
c.structure([], Union[A, B])
134+
135+
# Also test the fallback case
136+
with pytest.raises(ValueError):
137+
c.structure([], Union[A, B, C])
138+
139+
116140
@given(simple_classes(defaults=False))
117141
def test_fallback(cl_and_vals):
118142
"""The fallback case works."""

0 commit comments

Comments
 (0)