Skip to content

Commit 590021d

Browse files
authored
[codegen] Don't provide two defaults (#90)
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.
1 parent 3901dd1 commit 590021d

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

replit_river/codegen/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,7 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
380380
if name not in type.required:
381381
value = ""
382382
if base_model != "TypedDict":
383-
args = f"alias='{name}', default=None"
384-
if field_value != "...":
385-
value = f" = Field({field_value}, {args})"
386-
else:
387-
value = f" = Field({args})"
383+
value = f"Field(default=None, alias='{name}')"
388384
current_chunks.append(f" kind: Optional[{type_name}]{value}")
389385
else:
390386
value = ""

0 commit comments

Comments
 (0)