1616import fire
1717import requests
1818import xmltodict
19- from requests .models import Request , Response
19+ from requests .models import Response
2020from typing_extensions import TypedDict
2121
2222CANONICAL_URI = "/"
@@ -141,8 +141,8 @@ def __str__(self) -> str:
141141 return (
142142 f"Error --> status = { self .status_code } , "
143143 f"code = { self .error_code } , "
144- f' { " code_type = " if self .code_type is not None else "" } '
145- f' { self .code_type + ", " if self .code_type is not None else "" } '
144+ f" { ' code_type = ' if self .code_type is not None else '' } "
145+ f" { self .code_type + ', ' if self .code_type is not None else '' } "
146146 f"Reason = { self .message } , "
147147 f"request_id = { self .request_id } "
148148 )
@@ -389,7 +389,7 @@ def make_request(self, call: str, **kwargs: CallParameters):
389389 "content-type" : self .CONTENT_TYPE ,
390390 "host" : self .host ,
391391 "x-amz-date" : self .date ,
392- "x-amz-target" : f' { self .API_NAME } _{ datetime .date .today ().strftime (" %Y%m%d" )} .{ call } ' ,
392+ "x-amz-target" : f" { self .API_NAME } _{ datetime .date .today ().strftime (' %Y%m%d' )} .{ call } " ,
393393 }
394394
395395 payload_hash = hashlib .sha256 (
@@ -521,7 +521,7 @@ def build_headers(self, target: str, json_parameters: str) -> Headers:
521521
522522 signed_headers = "host;x-amz-date;x-amz-target"
523523 canonical_headers = (
524- f"host:{ self .host } \n " f"x -amz-date:{ self .date } \n " f"x -amz-target:{ target } \n "
524+ f"host:{ self .host } \n x -amz-date:{ self .date } \n x -amz-target:{ target } \n "
525525 )
526526 headers = {
527527 "content-type" : self .CONTENT_TYPE ,
@@ -607,7 +607,7 @@ def get_parameters(
607607 # Specific to ICU
608608 if (
609609 self .authentication_method == "accesskey"
610- or self .authentication_method == None
610+ or self .authentication_method is None
611611 ):
612612 data .update ({"AuthenticationMethod" : "accesskey" })
613613
@@ -702,7 +702,7 @@ def build_headers(self, target: str, _) -> Headers:
702702
703703 signed_headers = "host;x-osc-date;x-osc-target"
704704 canonical_headers = (
705- f"host:{ self .host } \n " f"x -osc-date:{ self .date } \n " f"x -osc-target:{ target } \n "
705+ f"host:{ self .host } \n x -osc-date:{ self .date } \n x -osc-target:{ target } \n "
706706 )
707707 headers = {
708708 "Content-Type" : self .CONTENT_TYPE ,
@@ -733,15 +733,14 @@ def get_conf(profile: str) -> Configuration:
733733 for v in json_profiles :
734734 json_profile = json_profiles [v ]
735735 if "region" in json_profile :
736-
737736 # use default stuffs only when "region" is use
738737 # to keep region_name format retrocompatible
739- if not "host" in json_profile and not "endpoint" in json_profile :
738+ if "host" not in json_profile and "endpoint" not in json_profile :
740739 json_profile ["host" ] = DEFAULT_HOST
741- if not "https" in json_profile :
740+ if "https" not in json_profile :
742741 json_profile ["https" ] = True
743742
744- if not "region_name" in json_profile :
743+ if "region_name" not in json_profile :
745744 json_profile ["region_name" ] = json_profile ["region" ]
746745 del json_profile ["region" ]
747746 conf = cast (Mapping [str , Configuration ], json_profiles )
@@ -768,7 +767,6 @@ def api_connect(
768767 config_path : Optional [str ] = None ,
769768 ** kwargs : CallParameters ,
770769):
771-
772770 calls = {
773771 "api" : OSCCall ,
774772 "directlink" : DirectLinkCall ,
@@ -811,8 +809,8 @@ def main():
811809 global PASSWORD_ARG
812810 PASSWORD_ARG = argv [i + 1 ]
813811 elif a == "--bash_completion" :
814- f = open (BASH_COMPLETION_PATH , "r" )
815- print (f .read ())
812+ with open (BASH_COMPLETION_PATH , "r" ) as f :
813+ print (f .read ())
816814 sys .exit ()
817815 return 0
818816 elif a == "--version" :
0 commit comments