Commit ef9a192
committed
Fix mypy arg-type errors in generated discriminated union encoders
The codegen for discriminated union TypedDict encoders generates a ternary
chain like:
encode_Foo(x) if x['kind'] == 'foo' else encode_Bar(x)
mypy cannot narrow TypedDict union types through key-based ternary conditions,
so every branch (not just the last fallback) receives the full union type.
The multi-variant sub-discriminator path (len(oneof_ts) > 1) already had
`# type: ignore[arg-type]` on line 306, but the single-variant path
(the common case) was missing it.
This caused the pid2 codegen CI in ai-infra to fail when the scribe schema
added new shape-type discriminated union variants.1 parent 6c7a537 commit ef9a192
File tree
2 files changed
+3
-2
lines changed- src/replit_river/codegen
- tests/v1/codegen/snapshot/snapshots/test_unknown_enum/enumService
2 files changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
0 commit comments