@@ -118,7 +118,7 @@ def __init__(self, stream):
118118 self .conn = h11 .Connection (h11 .SERVER )
119119 # Our Server: header
120120 self .ident = " " .join (
121- ["h11-example-trio-server/{}" . format ( h11 .__version__ ) , h11 .PRODUCT_ID ]
121+ [f "h11-example-trio-server/{ h11 .__version__ } " , h11 .PRODUCT_ID ]
122122 ).encode ("ascii" )
123123 # A unique id for this connection, to include in debugging output
124124 # (useful for understanding what's going on if there are multiple
@@ -206,7 +206,7 @@ def basic_headers(self):
206206
207207 def info (self , * args ):
208208 # Little debugging method
209- print ("{}:" . format ( self ._obj_id ) , * args )
209+ print (f" { self ._obj_id } :" , * args )
210210
211211
212212################################################################
@@ -253,7 +253,7 @@ async def http_serve(stream):
253253 if type (event ) is h11 .Request :
254254 await send_echo_response (wrapper , event )
255255 except Exception as exc :
256- wrapper .info ("Error during response handler: {!r}" . format ( exc ) )
256+ wrapper .info (f "Error during response handler: { exc !r} " )
257257 await maybe_send_error_response (wrapper , exc )
258258
259259 if wrapper .conn .our_state is h11 .MUST_CLOSE :
@@ -268,7 +268,7 @@ async def http_serve(stream):
268268 states = wrapper .conn .states
269269 wrapper .info ("unexpected state" , states , "-- bailing out" )
270270 await maybe_send_error_response (
271- wrapper , RuntimeError ("unexpected state {}" . format ( states ) )
271+ wrapper , RuntimeError (f "unexpected state { states } " )
272272 )
273273 await wrapper .shutdown_and_clean_up ()
274274 return
@@ -343,7 +343,7 @@ async def send_echo_response(wrapper, request):
343343
344344
345345async def serve (port ):
346- print ("listening on http://localhost:{}" . format ( port ) )
346+ print (f "listening on http://localhost:{ port } " )
347347 try :
348348 await trio .serve_tcp (http_serve , port )
349349 except KeyboardInterrupt :
0 commit comments