Skip to content

Commit ef9eacb

Browse files
Avoiding mixing type rendering and unstructured codegen
1 parent c2fe359 commit ef9eacb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/replit_river/codegen/client.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,16 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
643643
"""
644644
)
645645
current_chunks.append(
646-
f" kind: {render_type_expr(type_name)} | None{value}"
646+
f" kind: {
647+
render_type_expr(
648+
UnionTypeExpr(
649+
[
650+
type_name,
651+
NoneTypeExpr(),
652+
]
653+
)
654+
)
655+
}{value}"
647656
)
648657
else:
649658
value = ""
@@ -666,7 +675,11 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
666675
reindent(
667676
" ",
668677
f"""\
669-
{name}: NotRequired[{render_type_expr(type_name)}] | None
678+
{name}: NotRequired[{
679+
render_type_expr(
680+
UnionTypeExpr([type_name, NoneTypeExpr()])
681+
)
682+
}]
670683
""",
671684
)
672685
)
@@ -675,7 +688,16 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
675688
reindent(
676689
" ",
677690
f"""\
678-
{name}: {render_type_expr(type_name)} | None = None
691+
{name}: {
692+
render_type_expr(
693+
UnionTypeExpr(
694+
[
695+
type_name,
696+
NoneTypeExpr(),
697+
]
698+
)
699+
)
700+
} = None
679701
""",
680702
)
681703
)

0 commit comments

Comments
 (0)