Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/replit_river/codegen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down Expand Up @@ -301,9 +302,10 @@ def flatten_union(tpe: RiverType) -> list[RiverType]:
# "encoder_names" is only a TypedDict thing
encoder_names.add(encoder_name)
_field_name = render_literal_type(encoder_name)
_type_name = render_literal_type(type_name)
typeddict_encoder.append(
f"""\
{_field_name}(x) # type: ignore[arg-type]
{_field_name}(cast('{_type_name}', x))
""".strip()
)
if local_discriminators:
Expand Down Expand Up @@ -333,8 +335,10 @@ def flatten_union(tpe: RiverType) -> list[RiverType]:
# TODO(dstewart): Figure out why uncommenting this breaks
# generated code
# encoder_names.add(encoder_name)
_type_name = render_literal_type(type_name)
typeddict_encoder.append(
f"{render_literal_type(encoder_name)}(x)"
f"{render_literal_type(encoder_name)}"
f"(cast('{_type_name}', x))"
)
typeddict_encoder.append(
f"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down Expand Up @@ -71,9 +72,13 @@ def encode_NeedsenumobjectInput(
x: "NeedsenumobjectInput",
) -> Any:
return (
encode_NeedsenumobjectInputOneOf_in_first(x)
encode_NeedsenumobjectInputOneOf_in_first(
cast("NeedsenumobjectInputOneOf_in_first", x)
)
if x["kind"] == "in_first"
else encode_NeedsenumobjectInputOneOf_in_second(x)
else encode_NeedsenumobjectInputOneOf_in_second(
cast("NeedsenumobjectInputOneOf_in_second", x)
)
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Mapping,
NotRequired,
TypedDict,
cast,
)
from typing_extensions import Annotated

Expand Down
Loading