Repository navigation
Commit 280f78d
committed
Raise
`frequenz-quantities` 1.0.2 changed its `marshmallow` optional dependency
floor from `< 4` to `>= 4` (frequenz-floss/frequenz-quantities-python#107),
correcting metadata that had been wrong since that library was ported to
`marshmallow` 4. That cap was the only thing holding us on `marshmallow`
3, as our own requirement has allowed `< 5` since 870e880, so CI now
resolves `marshmallow` 4.
`marshmallow` 4 removed support for validators that signal failure by
returning `False`, deprecated in 3.24.0:
Custom validators must raise a `ValidationError` for invalid values
(deprecated in 3.24.0). Returning `False` is no longer supported.
The configuration test dataclasses used exactly that pattern, a
`lambda s: s.startswith("test")` in the field metadata. The validator is
still registered and still called, only its return value is ignored, so
the invalid value is accepted and `test_load_config_dataclass` and
`test_new_receiver_configurations[Validation Error]` fail.
Replacing the lambdas with a function that raises restores the checks.
The message stays `Invalid value.`, which is what `marshmallow` 3 emitted
through its `validator_failed` error key, so the expected output in
`test_manager.py` is unchanged and the surrounding test cases remain
consistent in asserting on `marshmallow`'s stock messages.
Nothing under `src/` needed changing: the validators there are
`marshmallow.validate.Range` and `OneOf`, which already raise. A raising
validator also works on `marshmallow` 3, so the supported range is not
narrowed, but the same silent acceptance can hit users who wrote their
own boolean validators, hence the release notes entry.
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>ValidationError from the config test validators1 parent 9e92877 commit 280f78d
3 files changed
Lines changed: 31 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
27 | | - | |
| 40 | + | |
28 | 41 | | |
29 | 42 | | |
30 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
20 | 33 | | |
21 | | - | |
| 34 | + | |
22 | 35 | | |
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
29 | | - | |
| 42 | + | |
30 | 43 | | |
31 | 44 | | |
32 | 45 | | |
| |||
0 commit comments