@@ -103,28 +103,28 @@ def __init__(self, cert: str) -> None:
103103 IOError: If the specified certificate file doesn't exist or cannot be read.
104104 ValueError: If the specified certificate is invalid.
105105 """
106- super (Certificate , self ).__init__ ()
106+ super ().__init__ ()
107107 if _is_file_path (cert ):
108- with open (cert ) as json_file :
108+ with open (cert , encoding = "utf-8" ) as json_file :
109109 json_data = json .load (json_file )
110110 elif isinstance (cert , dict ):
111111 json_data = cert
112112 else :
113113 raise ValueError (
114- 'Invalid certificate argument: "{0 }". Certificate argument must be a file path, '
115- 'or a dict containing the parsed file contents.' . format ( cert ) )
114+ f 'Invalid certificate argument: "{ cert } ". Certificate argument must be a file '
115+ 'path, or a dict containing the parsed file contents.' )
116116
117117 if json_data .get ('type' ) != self ._CREDENTIAL_TYPE :
118118 raise ValueError ('Invalid service account certificate. Certificate must contain a '
119- '"type" field set to "{0 }".' . format ( self . _CREDENTIAL_TYPE ) )
119+ f '"type" field set to "{ self . _CREDENTIAL_TYPE } ".' )
120120 try :
121121 self ._g_credential = service_account .Credentials .from_service_account_info (
122122 json_data , scopes = _scopes )
123123 self ._g_credential_async = service_account_async .Credentials .from_service_account_info (
124124 json_data , scopes = _scopes )
125125 except ValueError as error :
126126 raise ValueError ('Failed to initialize a certificate credential. '
127- 'Caused by: "{0 }"' . format ( error ))
127+ f 'Caused by: "{ error } "') from error
128128
129129 @property
130130 def project_id (self ) -> str :
@@ -162,7 +162,7 @@ def __init__(self) -> None:
162162 The credentials will be lazily initialized when get_credential(), get_credential_async()
163163 or project_id() is called. See those methods for possible errors raised.
164164 """
165- super (ApplicationDefault , self ).__init__ ()
165+ super ().__init__ ()
166166 self ._g_credential = None # Will be lazily-loaded via _load_credential().
167167 self ._g_credential_async = None # Will be lazily-loaded via _load_credential_async().
168168
@@ -229,20 +229,20 @@ def __init__(self, refresh_token: str) -> None:
229229 IOError: If the specified file doesn't exist or cannot be read.
230230 ValueError: If the refresh token configuration is invalid.
231231 """
232- super (RefreshToken , self ).__init__ ()
232+ super ().__init__ ()
233233 if _is_file_path (refresh_token ):
234- with open (refresh_token ) as json_file :
234+ with open (refresh_token , encoding = "utf-8" ) as json_file :
235235 json_data = json .load (json_file )
236236 elif isinstance (refresh_token , dict ):
237237 json_data = refresh_token
238238 else :
239239 raise ValueError (
240- 'Invalid refresh token argument: "{0 }". Refresh token argument must be a file '
241- 'path, or a dict containing the parsed file contents.' . format ( refresh_token ) )
240+ f 'Invalid refresh token argument: "{ refresh_token } ". Refresh token argument must be'
241+ ' a file path, or a dict containing the parsed file contents.' )
242242
243243 if json_data .get ('type' ) != self ._CREDENTIAL_TYPE :
244244 raise ValueError ('Invalid refresh token configuration. JSON must contain a '
245- '"type" field set to "{0 }".' . format ( self . _CREDENTIAL_TYPE ) )
245+ f '"type" field set to "{ self . _CREDENTIAL_TYPE } ".' )
246246 self ._g_credential = credentials .Credentials .from_authorized_user_info (json_data , _scopes )
247247 self ._g_credential_async = credentials_async .Credentials .from_authorized_user_info (
248248 json_data ,
0 commit comments