Skip to content

Commit a17379a

Browse files
Sort members to avoid shuffling on regen
1 parent 3105115 commit a17379a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

replit_river/codegen/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ def flatten_union(tpe: RiverType) -> list[RiverType]:
270270
for oneof_t in one_of_candidate_types:
271271
discriminator_value = [
272272
_NON_ALNUM_RE.sub("", str(prop.const))
273-
for name, prop in oneof_t.properties.items()
273+
for name, prop in sorted(
274+
list(oneof_t.properties.items()), key=lambda kv: kv[0]
275+
)
274276
if isinstance(prop, RiverConcreteType)
275277
and name == discriminator_name
276278
and prop.const is not None
@@ -533,7 +535,10 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
533535
if type.properties:
534536
needs_binding = True
535537
typeddict_encoder.append("{")
536-
for name, prop in type.properties.items():
538+
for (
539+
name,
540+
prop,
541+
) in sorted(list(type.properties.items()), key=lambda xs: xs[0]):
537542
typeddict_encoder.append(f"'{name}':")
538543
type_name, _, contents, _ = encode_type(
539544
prop, TypeName(prefix + name.title()), base_model, in_module

0 commit comments

Comments
 (0)