@@ -771,7 +771,14 @@ def generate_common_client(
771771 handshake_type : HandshakeType ,
772772 handshake_chunks : Sequence [str ],
773773 modules : list [tuple [ModuleName , ClassName ]],
774+ protocol_version : Literal ['v1.1' , 'v2.0' ],
774775) -> FileContents :
776+ client_module : str
777+ match protocol_version :
778+ case "v1.1" :
779+ client_module = "river"
780+ case "v2.0" :
781+ client_module = "river.v2"
775782 chunks : list [str ] = [ROOT_FILE_HEADER ]
776783 chunks .extend (
777784 [
@@ -785,7 +792,7 @@ def generate_common_client(
785792 dedent (
786793 f"""\
787794 class { client_name } :
788- def __init__(self, client: river .Client[{ handshake_type } ]):
795+ def __init__(self, client: { client_module } .Client[{ handshake_type } ]):
789796 """ .rstrip ()
790797 )
791798 ]
@@ -1048,12 +1055,19 @@ def _type_adapter_definition(
10481055 ],
10491056 )
10501057
1058+ client_module : str
1059+ match protocol_version :
1060+ case "v1.1" :
1061+ client_module = "river"
1062+ case "v2.0" :
1063+ client_module = "river.v2"
1064+
10511065 class_name = ClassName (f"{ schema_name .title ()} Service" )
10521066 current_chunks : list [str ] = [
10531067 dedent (
10541068 f"""\
10551069 class { class_name } :
1056- def __init__(self, client: river .Client[Any]):
1070+ def __init__(self, client: { client_module } .Client[Any]):
10571071 self.client = client
10581072 """
10591073 ),
@@ -1345,7 +1359,11 @@ def generate_river_client_module(
13451359 modules .append ((module_name , class_name ))
13461360
13471361 main_contents = generate_common_client (
1348- client_name , handshake_type , handshake_chunks , modules
1362+ client_name ,
1363+ handshake_type ,
1364+ handshake_chunks ,
1365+ modules ,
1366+ protocol_version ,
13491367 )
13501368 files [RenderedPath (str (Path ("__init__.py" )))] = main_contents
13511369
0 commit comments