@@ -99,8 +99,7 @@ def __del__(self):
9999 self .close ()
100100
101101 def __repr__ (self ):
102- return '{}(language={!r}, motherTongue={!r})' .format (
103- self .__class__ .__name__ , self .language , self .motherTongue )
102+ return f'{ self .__class__ .__name__ } (language={ self .language !r} , motherTongue={ self .motherTongue !r} )'
104103
105104 def close (self ):
106105 if self ._server_is_alive ():
@@ -188,10 +187,9 @@ def _get_valid_spelling_file_path() -> str:
188187 )
189188 if not os .path .exists (spelling_file_path ):
190189 raise FileNotFoundError (
191- "Failed to find the spellings file at {}\n "
190+ f "Failed to find the spellings file at { spelling_file_path } \n "
192191 "Please file an issue at "
193- "https://github.com/jxmorris12/language_tool_python/issues"
194- .format (spelling_file_path ))
192+ "https://github.com/jxmorris12/language_tool_python/issues" )
195193 return spelling_file_path
196194
197195 def _register_spellings (self ):
@@ -205,7 +203,7 @@ def _register_spellings(self):
205203 spellings_file .write ("\n " )
206204 spellings_file .write ("\n " .join (new_spellings ))
207205 if DEBUG_MODE :
208- print ("Registered new spellings at {}" . format ( spelling_file_path ) )
206+ print (f "Registered new spellings at { spelling_file_path } " )
209207
210208 def _unregister_spellings (self ):
211209 spelling_file_path = self ._get_valid_spelling_file_path ()
@@ -258,9 +256,8 @@ def _query_server(self, url, params=None, num_tries=2):
258256 except json .decoder .JSONDecodeError as e :
259257 if DEBUG_MODE :
260258 print (
261- 'URL {} and params {} '
262- 'returned invalid JSON response: {}'
263- .format (url , params , e )
259+ f'URL { url } and params { params } '
260+ f'returned invalid JSON response: { e } '
264261 )
265262 print (response )
266263 print (response .content )
@@ -270,11 +267,11 @@ def _query_server(self, url, params=None, num_tries=2):
270267 self ._terminate_server ()
271268 self ._start_local_server ()
272269 if n + 1 >= num_tries :
273- raise LanguageToolError ('{ }: {}' . format ( self . _url , e ) )
270+ raise LanguageToolError (f' { self . _url } : { e } ' )
274271
275272 def _start_server_on_free_port (self ):
276273 while True :
277- self ._url = 'http://{}:{}/v2/' . format ( self . _host , self . _port )
274+ self ._url = f 'http://{ self . _host } :{ self . _port } /v2/'
278275 try :
279276 self ._start_local_server ()
280277 break
@@ -327,10 +324,7 @@ def _start_local_server(self):
327324 if match :
328325 port = int (match .group (1 ))
329326 if port != self ._port :
330- raise LanguageToolError (
331- 'requested port {}, but got {}'
332- .format (self ._port , port )
333- )
327+ raise LanguageToolError (f'requested port { self ._port } , but got { port } ' )
334328 break
335329 if not match :
336330 err_msg = self ._terminate_server ()
0 commit comments