Commit d9e0b3f
committed
fix(cddl2py): emit valid Python for .regexp operator
The template-annotated pattern logic produced invalid expressions like
`Annotated[str, "custom:" + str]`, which fails at runtime because you
cannot concatenate a string literal with the str type object. Complex
patterns (e.g. `[^@]+@[^@]+`) were also silently downgraded to bare
`str`, losing the constraint even in pydantic mode.
Store the regex pattern as a plain string annotation instead
(`Annotated[str, "custom:.+"]`), which is valid Python and preserves
the constraint as inspectable metadata.1 parent c6d0a86 commit d9e0b3f
2 files changed
Lines changed: 23 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | 520 | | |
552 | 521 | | |
553 | 522 | | |
| |||
566 | 535 | | |
567 | 536 | | |
568 | 537 | | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | 538 | | |
578 | 539 | | |
579 | 540 | | |
580 | 541 | | |
581 | 542 | | |
582 | 543 | | |
583 | | - | |
| 544 | + | |
584 | 545 | | |
585 | 546 | | |
586 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
208 | 222 | | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
218 | 232 | | |
219 | 233 | | |
| 234 | + | |
| 235 | + | |
220 | 236 | | |
221 | 237 | | |
222 | 238 | | |
| |||
0 commit comments