Commit bd88e45
authored
Fix codegen crashes for intersection types and complex list inner types (#172)
Why
===
Codegen fails when a schema contains intersection types (`allOf`) or
lists with complex inner types (e.g. `list[dict[str, Any]]`). Both crash
with `Complex type must be put through render_type_expr!` or `Unexpected
expression when expecting a type name: DictTypeExpr(...)` because
`TypeName` objects are used directly in f-strings or passed to
`ensure_literal_type` which only accepts simple `TypeName` values.
What changed
============
- Fix `TypeName.__str__()` crash in the `RiverIntersectionType` encoder
by wrapping `encoder_name` with `render_literal_type()`, matching the
existing pattern used by `RiverUnionType` (line 625) and
`RiverConcreteType` (line 654)
- Fix `ensure_literal_type` crash when a list's inner type is a complex
expression (e.g. `list[dict[str, Any]]`) by guarding the `ListTypeExpr`
match to only enter the encoding branch for `TypeName` inner types,
falling through to `list(x)` for composite types that don't need
encoding
Test plan
=========
_Describe what you did to test this change to a level of detail that
allows your reviewer to test it_1 parent f216da6 commit bd88e45
1 file changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
411 | 413 | | |
412 | 414 | | |
413 | 415 | | |
| |||
633 | 635 | | |
634 | 636 | | |
635 | 637 | | |
636 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
637 | 641 | | |
638 | 642 | | |
639 | 643 | | |
| |||
0 commit comments