Skip to content

Commit

Permalink
[codegen] Don't provide two defaults (#90)
Browse files Browse the repository at this point in the history
Why
===

Turns out that if we have an optional literal field, we were trying to
provide a default for the literal and also for the optional. mypy was
not having it.

What changed
============

This change chooses just one: the optional.

Test plan
=========


https://replit.semaphoreci.com/jobs/8dac3b8a-1803-4903-8acd-515e278789f2/summary
does not happen anymore.
  • Loading branch information
lhchavez committed Sep 27, 2024
1 parent 3901dd1 commit 590021d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions replit_river/codegen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,7 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
if name not in type.required:
value = ""
if base_model != "TypedDict":
args = f"alias='{name}', default=None"
if field_value != "...":
value = f" = Field({field_value}, {args})"
else:
value = f" = Field({args})"
value = f"Field(default=None, alias='{name}')"
current_chunks.append(f" kind: Optional[{type_name}]{value}")
else:
value = ""
Expand Down

0 comments on commit 590021d

Please sign in to comment.