Skip to content

Commit 1c06a0b

Browse files
[feat] Disable pyright checking field Pydantic field aliases (#102)
Why === If we ignore the alias field, we can use pyright to typecheck python generated clients. What changed ============ Reflow the field assignment to permit ignoring type aliases like `alias="$kind"` Test plan ========= Manually ran against production services, typechecked OK
1 parent 988c540 commit 1c06a0b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

replit_river/codegen/client.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,26 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
403403
if name not in type.required:
404404
value = ""
405405
if base_model != "TypedDict":
406-
value = f" = Field(default=None, alias='{name}')"
406+
value = dedent(
407+
f"""\
408+
= Field(
409+
default=None,
410+
alias='{name}', # type: ignore
411+
)
412+
"""
413+
)
407414
current_chunks.append(f" kind: Optional[{type_name}]{value}")
408415
else:
409416
value = ""
410417
if base_model != "TypedDict":
411-
value = f" = Field({field_value}, alias='{name}')"
418+
value = dedent(
419+
f"""\
420+
= Field(
421+
{field_value},
422+
alias='{name}', # type: ignore
423+
)
424+
"""
425+
)
412426
current_chunks.append(f" kind: {type_name}{value}")
413427
else:
414428
if name not in type.required:

0 commit comments

Comments
 (0)