File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ async def run_enhanced_demo(
193
193
print ("🖥️ ENHANCED ECHO SERVER MODE" )
194
194
print ("=" * 60 )
195
195
196
- # Set the enhanced stream handler
196
+ # type: ignore: Stream is type of NetStream
197
197
host .set_stream_handler (PROTOCOL_ID , enhanced_echo_handler )
198
198
199
199
print (
@@ -217,7 +217,8 @@ async def run_enhanced_demo(
217
217
218
218
# Create stream and run enhanced demo
219
219
stream = await host .new_stream (info .peer_id , [PROTOCOL_ID ])
220
- await enhanced_client_demo (stream )
220
+ if isinstance (stream , NetStream ):
221
+ await enhanced_client_demo (stream )
221
222
222
223
print ("\n " + "=" * 60 )
223
224
print ("CLIENT DEMO COMPLETE" )
Original file line number Diff line number Diff line change 1
1
from enum import (
2
2
Enum ,
3
3
)
4
- from typing import (
5
- Optional ,
6
- )
7
4
8
5
import trio
9
6
@@ -102,11 +99,11 @@ class NetStream(INetStream):
102
99
"""
103
100
104
101
muxed_stream : IMuxedStream
105
- protocol_id : Optional [ TProtocol ]
102
+ protocol_id : TProtocol | None
106
103
__stream_state : StreamState
107
104
108
105
def __init__ (
109
- self , muxed_stream : IMuxedStream , nursery : Optional [ trio .Nursery ] = None
106
+ self , muxed_stream : IMuxedStream , nursery : trio .Nursery | None = None
110
107
) -> None :
111
108
super ().__init__ ()
112
109
@@ -142,7 +139,7 @@ async def state(self) -> StreamState:
142
139
async with self ._state_lock :
143
140
return self .__stream_state
144
141
145
- async def read (self , n : Optional [ int ] = None ) -> bytes :
142
+ async def read (self , n : int | None = None ) -> bytes :
146
143
"""
147
144
Read from stream.
148
145
@@ -279,7 +276,7 @@ async def _notify_closed(self) -> None:
279
276
if hasattr (swarm , "refs" ) and hasattr (swarm .refs , "done" ):
280
277
swarm .refs .done ()
281
278
282
- def get_remote_address (self ) -> Optional [ tuple [str , int ]] :
279
+ def get_remote_address (self ) -> tuple [str , int ] | None :
283
280
"""Delegate to the underlying muxed stream."""
284
281
return self .muxed_stream .get_remote_address ()
285
282
You can’t perform that action at this time.
0 commit comments