Commit 418a210
Tell the caller how to fix a subset violation
The message stated the constraint and left the remedy to be inferred:
"given_name_titles must be a subset of titles; not in titles: سيد".
Since adding to both fields is the only thing the caller can have
meant, the error should say so.
given_name_titles marks a subset of titles; not in titles: سيد.
Add them to titles as well — add(titles={...}, given_name_titles={...})
Considered auto-adding to the base field instead, and rejected it for
2.0: a typo in a marker field would silently mint new vocabulary
(add(given_name_titles={"profesor"}) inventing a title), the same
inference would have to extend to the other two marker pairs and to
remove()'s cascade, and the direction is one-way -- strict now can
relax in 2.1, loose now can never tighten. The message carries most of
the ergonomic benefit at none of that cost.
Parametrized over all three marker pairs, via constructor lambdas
rather than **kwargs: Lexicon's signature is heterogeneous
(capitalization_exceptions is pair-valued), so dynamic kwargs fail
mypy, and tests/ is type-checked here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent d8feb3e commit 418a210
2 files changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
241 | 257 | | |
242 | 258 | | |
243 | 259 | | |
| |||
0 commit comments