Skip to content

Commit

Permalink
If we ignore the alias field, we can use pyright to typecheck python …
Browse files Browse the repository at this point in the history
…generated clients
  • Loading branch information
blast-hardcheese committed Oct 25, 2024
1 parent 988c540 commit 140b0e7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions replit_river/codegen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,26 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
if name not in type.required:
value = ""
if base_model != "TypedDict":
value = f" = Field(default=None, alias='{name}')"
value = dedent(
f"""\
= Field(
default=None,
alias='{name}', # type: ignore
)
"""
)
current_chunks.append(f" kind: Optional[{type_name}]{value}")
else:
value = ""
if base_model != "TypedDict":
value = f" = Field({field_value}, alias='{name}')"
value = dedent(
f"""\
= Field(
{field_value},
alias='{name}', # type: ignore
)
"""
)
current_chunks.append(f" kind: {type_name}{value}")
else:
if name not in type.required:
Expand Down

0 comments on commit 140b0e7

Please sign in to comment.