@@ -265,7 +265,7 @@ def token_endpoint(self) -> str:
265265 if params is None :
266266 raise RSConnectException ("No Snowflake connection found." )
267267
268- return "https://{}.snowflakecomputing.com/" . format ( params [ "account" ])
268+ return f "https://{ params [ 'account' ] } .snowflakecomputing.com/"
269269
270270 def fmt_payload (self ):
271271 params = get_parameters (self .snowflake_connection_name )
@@ -276,9 +276,7 @@ def fmt_payload(self):
276276 authenticator = params .get ("authenticator" )
277277 if authenticator == "SNOWFLAKE_JWT" :
278278 spcs_url = urlparse (self .url )
279- scope = (
280- "session:role:{} {}" .format (params ["role" ], spcs_url .netloc ) if params .get ("role" ) else spcs_url .netloc
281- )
279+ scope = f"session:role:{ params ['role' ]} { spcs_url .netloc } " if params .get ("role" ) else spcs_url .netloc
282280 jwt = generate_jwt (self .snowflake_connection_name )
283281 grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer"
284282
@@ -300,13 +298,13 @@ def fmt_payload(self):
300298 "body" : payload ,
301299 "headers" : {
302300 "Content-Type" : "application/json" ,
303- "Authorization" : "Bearer %s" % params [" token" ] ,
301+ "Authorization" : f "Bearer { params [' token' ] } " ,
304302 "X-Snowflake-Authorization-Token-Type" : "OAUTH" ,
305303 },
306304 "path" : "/session/v1/login-request" ,
307305 }
308306 else :
309- raise NotImplementedError ("Unsupported authenticator for SPCS Connect: %s" % authenticator )
307+ raise NotImplementedError (f "Unsupported authenticator for SPCS Connect: { authenticator } " )
310308
311309 def exchange_token (self ) -> str :
312310 try :
@@ -451,13 +449,13 @@ def python_settings(self) -> PyInfo:
451449 return response
452450
453451 def app_get (self , app_id : str ) -> ContentItemV0 :
454- response = cast (Union [ContentItemV0 , HTTPResponse ], self .get ("applications/%s" % app_id ))
452+ response = cast (Union [ContentItemV0 , HTTPResponse ], self .get (f "applications/{ app_id } " ))
455453 response = self ._server .handle_bad_response (response )
456454 return response
457455
458456 def add_environment_vars (self , content_guid : str , env_vars : list [tuple [str , str ]]):
459457 env_body = [dict (name = kv [0 ], value = kv [1 ]) for kv in env_vars ]
460- return self .patch ("v1/content/%s /environment" % content_guid , body = env_body )
458+ return self .patch (f "v1/content/{ content_guid } /environment" , body = env_body )
461459
462460 def is_failed_response (self , response : HTTPResponse | JsonData ) -> bool :
463461 return isinstance (response , HTTPResponse ) and response .status >= 500
@@ -481,15 +479,15 @@ def access_content(self, content_guid: str) -> None:
481479 def bundle_download (self , content_guid : str , bundle_id : str ) -> HTTPResponse :
482480 response = cast (
483481 HTTPResponse ,
484- self .get ("v1/content/%s /bundles/%s /download" % ( content_guid , bundle_id ) , decode_response = False ),
482+ self .get (f "v1/content/{ content_guid } /bundles/{ bundle_id } /download" , decode_response = False ),
485483 )
486484 response = self ._server .handle_bad_response (response , is_httpresponse = True )
487485 return response
488486
489487 def content_lockfile (self , content_guid : str ) -> HTTPResponse :
490488 response = cast (
491489 HTTPResponse ,
492- self .get ("v1/content/%s /lockfile" % content_guid , decode_response = False ),
490+ self .get (f "v1/content/{ content_guid } /lockfile" , decode_response = False ),
493491 )
494492 response = self ._server .handle_bad_response (response , is_httpresponse = True )
495493 return response
@@ -500,7 +498,7 @@ def content_list(self, filters: Optional[Mapping[str, JsonData]] = None) -> list
500498 return response
501499
502500 def content_get (self , content_guid : str ) -> ContentItemV1 :
503- response = cast (Union [ContentItemV1 , HTTPResponse ], self .get ("v1/content/%s" % content_guid ))
501+ response = cast (Union [ContentItemV1 , HTTPResponse ], self .get (f "v1/content/{ content_guid } " ))
504502 response = self ._server .handle_bad_response (response )
505503 return response
506504
@@ -546,17 +544,17 @@ def upload_bundle(
546544 body , content_type = create_multipart_form_data (fields )
547545 response = cast (
548546 Union [BundleMetadata , HTTPResponse ],
549- self .post ("v1/content/%s /bundles" % content_guid , body = body , headers = {"Content-Type" : content_type }),
547+ self .post (f "v1/content/{ content_guid } /bundles" , body = body , headers = {"Content-Type" : content_type }),
550548 )
551549 else :
552550 response = cast (
553- Union [BundleMetadata , HTTPResponse ], self .post ("v1/content/%s /bundles" % content_guid , body = tarball )
551+ Union [BundleMetadata , HTTPResponse ], self .post (f "v1/content/{ content_guid } /bundles" , body = tarball )
554552 )
555553 response = self ._server .handle_bad_response (response )
556554 return response
557555
558556 def content_update (self , content_guid : str , updates : Mapping [str , str | None ]) -> ContentItemV1 :
559- response = cast (Union [ContentItemV1 , HTTPResponse ], self .patch ("v1/content/%s" % content_guid , body = updates ))
557+ response = cast (Union [ContentItemV1 , HTTPResponse ], self .patch (f "v1/content/{ content_guid } " , body = updates ))
560558 response = self ._server .handle_bad_response (response )
561559 return response
562560
@@ -571,7 +569,7 @@ def content_build(
571569 body ["activate" ] = False
572570 response = cast (
573571 Union [BuildOutputDTO , HTTPResponse ],
574- self .post ("v1/content/%s /build" % content_guid , body = body ),
572+ self .post (f "v1/content/{ content_guid } /build" , body = body ),
575573 )
576574 response = self ._server .handle_bad_response (response )
577575 return response
@@ -587,7 +585,7 @@ def content_deploy(
587585 body ["activate" ] = False
588586 response = cast (
589587 Union [BuildOutputDTO , HTTPResponse ],
590- self .post ("v1/content/%s /deploy" % content_guid , body = body ),
588+ self .post (f "v1/content/{ content_guid } /deploy" , body = body ),
591589 )
592590 response = self ._server .handle_bad_response (response )
593591 return response
@@ -615,7 +613,7 @@ def task_get(
615613 params ["first" ] = first
616614 if wait is not None :
617615 params ["wait" ] = wait
618- response = cast (Union [TaskStatusV1 , HTTPResponse ], self .get ("v1/tasks/%s" % task_id , query_params = params ))
616+ response = cast (Union [TaskStatusV1 , HTTPResponse ], self .get (f "v1/tasks/{ task_id } " , query_params = params ))
619617 response = self ._server .handle_bad_response (response )
620618
621619 # compatibility with rsconnect-jupyter
@@ -1102,11 +1100,11 @@ def make_bundle(
11021100 def upload_posit_bundle (self , prepare_deploy_result : PrepareDeployResult , bundle_size : int , contents : bytes ):
11031101 upload_url = prepare_deploy_result .presigned_url
11041102 parsed_upload_url = urlparse (upload_url )
1105- with S3Client ("{ }://{}" . format ( parsed_upload_url .scheme , parsed_upload_url . netloc ) ) as s3_client :
1103+ with S3Client (f" { parsed_upload_url . scheme } ://{ parsed_upload_url .netloc } " ) as s3_client :
11061104 upload_result = cast (
11071105 HTTPResponse ,
11081106 s3_client .upload (
1109- "{ }?{}" . format ( parsed_upload_url .path , parsed_upload_url . query ) ,
1107+ f" { parsed_upload_url . path } ?{ parsed_upload_url .query } " ,
11101108 prepare_deploy_result .presigned_checksum ,
11111109 bundle_size ,
11121110 contents ,
@@ -1156,7 +1154,7 @@ def deploy_bundle(self, activate: bool = True):
11561154 # type: ignore[arg-type] - PrepareDeployResult uses int, but format() accepts it
11571155 shinyapps_service .do_deploy (prepare_deploy_result .bundle_id , prepare_deploy_result .app_id )
11581156
1159- print ("Application successfully deployed to {}" . format ( prepare_deploy_result .app_url ) )
1157+ print (f "Application successfully deployed to { prepare_deploy_result .app_url } " )
11601158 webbrowser .open_new (prepare_deploy_result .app_url )
11611159
11621160 self .deployed_info = RSConnectClientDeployResult (
@@ -1577,21 +1575,21 @@ def get_extra_headers(self, url: str, method: str, body: str | bytes):
15771575 signature = self ._get_canonical_request_signature (canonical_request )
15781576
15791577 return {
1580- "X-Auth-Token" : "{0}" . format ( self ._token ) ,
1581- "X-Auth-Signature" : "{0 }; version=1". format ( signature ) ,
1578+ "X-Auth-Token" : self ._token ,
1579+ "X-Auth-Signature" : f" { signature } ; version=1" ,
15821580 "Date" : canonical_request_date ,
15831581 "X-Content-Checksum" : canonical_request_checksum ,
15841582 }
15851583
15861584 def get_application (self , application_id : str ):
1587- response = cast (Union [PositClientApp , HTTPResponse ], self .get ("/v1/applications/{}" . format ( application_id ) ))
1585+ response = cast (Union [PositClientApp , HTTPResponse ], self .get (f "/v1/applications/{ application_id } " ))
15881586 response = self ._server .handle_bad_response (response )
15891587 return response
15901588
15911589 def update_application_property (self , application_id : int , property : str , value : str ) -> HTTPResponse :
15921590 response = cast (
15931591 HTTPResponse ,
1594- self .put ("/v1/applications/{}/properties/{}" . format ( application_id , property ) , body = {"value" : value }),
1592+ self .put (f "/v1/applications/{ application_id } /properties/{ property } " , body = {"value" : value }),
15951593 )
15961594 response = self ._server .handle_bad_response (response , is_httpresponse = True )
15971595 return response
@@ -1614,11 +1612,7 @@ def get_accounts(self) -> PositClientAccountSearchResults:
16141612 def _get_applications_like_name_page (self , name : str , offset : int ) -> PositClientAppSearchResults :
16151613 response = cast (
16161614 Union [PositClientAppSearchResults , HTTPResponse ],
1617- self .get (
1618- "/v1/applications?filter=name:like:{}&offset={}&count=100&use_advanced_filters=true" .format (
1619- name , offset
1620- )
1621- ),
1615+ self .get (f"/v1/applications?filter=name:like:{ name } &offset={ offset } &count=100&use_advanced_filters=true" ),
16221616 )
16231617 response = self ._server .handle_bad_response (response )
16241618 return response
@@ -1637,22 +1631,22 @@ def create_bundle(
16371631 return response
16381632
16391633 def set_bundle_status (self , bundle_id : str , bundle_status : str ):
1640- response = self .post ("/v1/bundles/{}/status" . format ( bundle_id ) , body = {"status" : bundle_status })
1634+ response = self .post (f "/v1/bundles/{ bundle_id } /status" , body = {"status" : bundle_status })
16411635 response = self ._server .handle_bad_response (response )
16421636 return response
16431637
16441638 def deploy_application (self , bundle_id : str , app_id : str ) -> PositClientDeployTask :
16451639 response = cast (
16461640 Union [PositClientDeployTask , HTTPResponse ],
1647- self .post ("/v1/applications/{}/deploy" . format ( app_id ) , body = {"bundle" : bundle_id , "rebuild" : False }),
1641+ self .post (f "/v1/applications/{ app_id } /deploy" , body = {"bundle" : bundle_id , "rebuild" : False }),
16481642 )
16491643 response = self ._server .handle_bad_response (response )
16501644 return response
16511645
16521646 def get_task (self , task_id : str ) -> PositClientDeployTask :
16531647 response = cast (
16541648 Union [PositClientDeployTask , HTTPResponse ],
1655- self .get ("/v1/tasks/{}" . format ( task_id ) , query_params = {"legacy" : "true" }),
1649+ self .get (f "/v1/tasks/{ task_id } " , query_params = {"legacy" : "true" }),
16561650 )
16571651 response = self ._server .handle_bad_response (response )
16581652 return response
@@ -1664,7 +1658,7 @@ def get_shinyapps_build_task(self, parent_task_id: str) -> PositClientShinyappsB
16641658 "/v1/tasks" ,
16651659 query_params = {
16661660 "filter" : [
1667- "parent_id:eq:{}" . format ( parent_task_id ) ,
1661+ f "parent_id:eq:{ parent_task_id } " ,
16681662 "action:eq:image-build" ,
16691663 ]
16701664 },
@@ -1674,7 +1668,7 @@ def get_shinyapps_build_task(self, parent_task_id: str) -> PositClientShinyappsB
16741668 return response
16751669
16761670 def get_task_logs (self , task_id : str ) -> HTTPResponse :
1677- response = cast (HTTPResponse , self .get ("/v1/tasks/{}/logs" . format ( task_id ) ))
1671+ response = cast (HTTPResponse , self .get (f "/v1/tasks/{ task_id } /logs" ))
16781672 response = self ._server .handle_bad_response (response , is_httpresponse = True )
16791673 return response
16801674
@@ -1685,7 +1679,7 @@ def get_current_user(self):
16851679
16861680 def wait_until_task_is_successful (self , task_id : str , timeout : int = get_task_timeout ()) -> None :
16871681 print ()
1688- print ("Waiting for task: {}" . format ( task_id ) )
1682+ print (f "Waiting for task: { task_id } " )
16891683
16901684 start_time = time .time ()
16911685 finished : bool | None = None
@@ -1703,16 +1697,16 @@ def wait_until_task_is_successful(self, task_id: str, timeout: int = get_task_ti
17031697 if finished :
17041698 break
17051699
1706- print (" {} - {}" . format ( status , description ) )
1700+ print (f " { status } - { description } " )
17071701 time .sleep (2 )
17081702
17091703 if not finished :
17101704 raise RSConnectException (get_task_timeout_help_message (timeout ))
17111705
17121706 if status != "success" :
1713- raise DeploymentFailedException ("Application deployment failed with error: {}" . format ( error ) )
1707+ raise DeploymentFailedException (f "Application deployment failed with error: { error } " )
17141708
1715- print ("Task done: {}" . format ( description ) )
1709+ print (f "Task done: { description } " )
17161710
17171711 def get_applications_like_name (self , name : str ) -> list [str ]:
17181712 applications : list [PositClientApp ] = []
@@ -1794,7 +1788,7 @@ def do_deploy(self, bundle_id: str, app_id: str):
17941788 build_task_result = self ._posit_client .get_shinyapps_build_task (deploy_task ["id" ])
17951789 build_task = build_task_result ["tasks" ][0 ]
17961790 logs = self ._posit_client .get_task_logs (build_task ["id" ])
1797- logger .error ("Build logs:\n {}" . format ( logs .response_body ) )
1791+ logger .error (f "Build logs:\n { logs .response_body } " )
17981792 raise e
17991793
18001794
0 commit comments