Skip to content

Commit 2ce9b17

Browse files
List -> list in code
1 parent 2dc8eff commit 2ce9b17

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

replit_river/codegen/client.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import (
55
Any,
66
Dict,
7-
List,
87
Literal,
98
Optional,
109
OrderedDict,
@@ -32,11 +31,11 @@ class RiverConcreteType(BaseModel):
3231

3332

3433
class RiverUnionType(BaseModel):
35-
anyOf: List["RiverType"]
34+
anyOf: list["RiverType"]
3635

3736

3837
class RiverIntersectionType(BaseModel):
39-
allOf: List["RiverType"]
38+
allOf: list["RiverType"]
4039

4140

4241
class RiverNotType(BaseModel):
@@ -93,7 +92,7 @@ def is_literal(tpe: RiverType) -> bool:
9392
def encode_type(
9493
type: RiverType, prefix: str, base_model: str
9594
) -> Tuple[str, Sequence[str]]:
96-
chunks: List[str] = []
95+
chunks: list[str] = []
9796
if isinstance(type, RiverNotType):
9897
return ("None", ())
9998
if isinstance(type, RiverUnionType):
@@ -114,7 +113,7 @@ def flatten_union(tpe: RiverType) -> list[RiverType]:
114113

115114
type = RiverUnionType(anyOf=flatten_union(type))
116115

117-
one_of_candidate_types: List[RiverConcreteType] = [
116+
one_of_candidate_types: list[RiverConcreteType] = [
118117
t
119118
for _t in type.anyOf
120119
for t in (_t.anyOf if isinstance(_t, RiverUnionType) else [_t])
@@ -160,7 +159,7 @@ def flatten_union(tpe: RiverType) -> list[RiverType]:
160159
(discriminator_value, []),
161160
)[1].append(oneof_t)
162161

163-
one_of: List[str] = []
162+
one_of: list[str] = []
164163
if discriminator_name == "$kind":
165164
discriminator_name = "kind"
166165
for pfx, (discriminator_value, oneof_ts) in one_of_pending.items():
@@ -234,7 +233,7 @@ def encode_{prefix}(x: {repr(prefix)}) -> Any:
234233
# End of stable union detection
235234
# Restore the non-flattened union type
236235
type = original_type
237-
any_of: List[str] = []
236+
any_of: list[str] = []
238237

239238
typeddict_encoder = []
240239
for i, t in enumerate(type.anyOf):
@@ -338,7 +337,7 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
338337
return (f"Dict[str, {type_name}]", type_chunks)
339338
assert type.type == "object", type.type
340339

341-
current_chunks: List[str] = [f"class {prefix}({base_model}):"]
340+
current_chunks: list[str] = [f"class {prefix}({base_model}):"]
342341
# For the encoder path, do we need "x" to be bound?
343342
# lambda x: ... vs lambda _: {}
344343
needs_binding = False
@@ -484,7 +483,7 @@ def generate_river_client_module(
484483
schema_root: RiverSchema,
485484
typed_dict_inputs: bool,
486485
) -> Sequence[str]:
487-
chunks: List[str] = [
486+
chunks: list[str] = [
488487
dedent(
489488
"""\
490489
# ruff: noqa
@@ -522,7 +521,7 @@ def generate_river_client_module(
522521

523522
input_base_class = "TypedDict" if typed_dict_inputs else "BaseModel"
524523
for schema_name, schema in schema_root.services.items():
525-
current_chunks: List[str] = [
524+
current_chunks: list[str] = [
526525
dedent(
527526
f"""\
528527
class {schema_name.title()}Service:

replit_river/codegen/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os.path
33
import tempfile
44
from textwrap import dedent
5-
from typing import DefaultDict, List, Sequence
5+
from typing import DefaultDict, Sequence
66

77
import black
88
import grpc_tools # type: ignore
@@ -47,7 +47,7 @@ def message_decoder(
4747
" return m",
4848
]
4949
# Non-oneof fields.
50-
oneofs: DefaultDict[int, List[descriptor_pb2.FieldDescriptorProto]] = (
50+
oneofs: DefaultDict[int, list[descriptor_pb2.FieldDescriptorProto]] = (
5151
collections.defaultdict(list)
5252
)
5353
for field in m.field:
@@ -159,7 +159,7 @@ def message_encoder(
159159
" d: Dict[str, Any] = {}",
160160
]
161161
# Non-oneof fields.
162-
oneofs: DefaultDict[int, List[descriptor_pb2.FieldDescriptorProto]] = (
162+
oneofs: DefaultDict[int, list[descriptor_pb2.FieldDescriptorProto]] = (
163163
collections.defaultdict(list)
164164
)
165165
for field in m.field:
@@ -225,7 +225,7 @@ def generate_river_module(
225225
fds: descriptor_pb2.FileDescriptorSet,
226226
) -> Sequence[str]:
227227
"""Generates the lines of a River module."""
228-
chunks: List[str] = [
228+
chunks: list[str] = [
229229
dedent(
230230
f"""\
231231
# Code generated by river.codegen. DO NOT EDIT.

0 commit comments

Comments
 (0)