@@ -87,7 +87,7 @@ def spell_check_file(filename, spell_checker, mime_type="", output_lvl=1, prefix
8787 mime_type = getMimeType (filename )
8888
8989 if output_lvl > 0 :
90- print ("spell_check_file:" , filename , "," , mime_type )
90+ print (f "spell_check_file: { filename } , { mime_type } " )
9191
9292 # Returns a list of comment_parser.parsers.common.Comments
9393 if mime_type == "text/plain" :
@@ -96,22 +96,22 @@ def spell_check_file(filename, spell_checker, mime_type="", output_lvl=1, prefix
9696 try :
9797 clist = comment_parser .extract_comments (filename , mime = mime_type )
9898 except BaseException :
99- print ("Parser failed, skipping file" , filename )
99+ print (f "Parser failed, skipping file { filename } " )
100100 return []
101101
102102 bad_words = []
103103
104104 for c in clist :
105105 if output_lvl > 1 :
106- print ("Comment: " , c )
106+ print (f "Comment: { c } " )
107107 print (type (c ))
108108
109109 mistakes = []
110110 spell_checker .set_text (c .text ())
111111
112112 for error in spell_checker :
113113 if output_lvl > 1 :
114- print ("Error:" , error .word )
114+ print (f "Error: { error .word } " )
115115
116116 # Check if the bad word starts with a prefix.
117117 # If so, spell check the word without that prefix.
@@ -125,17 +125,17 @@ def spell_check_file(filename, spell_checker, mime_type="", output_lvl=1, prefix
125125 # remove the prefix
126126 wrd = error .word [len (pre ) :]
127127 if output_lvl > 1 :
128- print ("Trying without prefix: " , error .word , wrd )
128+ print (f "Trying without ' { pre } ' prefix: { error .word } -> { wrd } " )
129129 try :
130130 if spell_checker .check (wrd ):
131131 continue
132132 except BaseException :
133- print ("Caught an exception for word" , error .word , wrd )
133+ print (f "Caught an exception for word { error .word } { wrd } " )
134134
135135 # Try splitting camel case words and checking each sub-word
136136
137137 if output_lvl > 1 :
138- print ("Trying splitting camel case word" )
138+ print (f "Trying splitting camel case word: { error . word } " )
139139 sub_words = splitCamelCase (error .word )
140140 if len (sub_words ) > 1 :
141141 ok_flag = True
@@ -153,26 +153,19 @@ def spell_check_file(filename, spell_checker, mime_type="", output_lvl=1, prefix
153153 continue
154154
155155 if output_lvl > 1 :
156- msg = (
157- "error: "
158- + "'"
159- + error .word
160- + "', "
161- + "suggestions: "
162- + str (spell_checker .suggest ())
163- )
156+ msg = f"error: '{ error .word } ', suggestions: { spell_checker .suggest ()} "
164157 else :
165158 msg = error .word
166159 mistakes .append (msg )
167160
168161 if len (mistakes ):
169162 if output_lvl > 0 :
170- print ("\n Line number" , c .line_number ())
163+ print (f "\n Line number { c .line_number ()} " )
171164 if output_lvl > 0 :
172165 print (c .text ())
173166 for m in mistakes :
174167 if output_lvl >= 0 :
175- print (" " , m )
168+ print (f " { m } " )
176169 bad_words .append ([m , filename , c .line_number ()])
177170
178171 bad_words = sorted (bad_words )
@@ -379,15 +372,15 @@ def main():
379372 suffixes = args .suffix
380373
381374 if output_lvl > 1 :
382- print ("Prefixes:" , prefixes )
383- print ("Suffixes:" , suffixes )
375+ print (f "Prefixes: { prefixes } " )
376+ print (f "Suffixes: { suffixes } " )
384377
385378 #
386379 # Spell check the files
387380 #
388381 for f in file_list :
389382 if not args .miss :
390- print ("\n Checking" , f )
383+ print (f "\n Checking { f } " )
391384
392385 # If f is a directory, recursively check for files in it.
393386 if os .path .isdir (f ):
@@ -403,11 +396,11 @@ def main():
403396 for x in dir_entries :
404397 if exclude_check (x , args .exclude ) or skip_check (x , args .skip ):
405398 if not args .miss :
406- print ("\n Excluding" , x )
399+ print (f "\n Excluding { x } " )
407400 continue
408401
409402 if not args .miss :
410- print ("\n Checking" , x )
403+ print (f "\n Checking { x } " )
411404 result = spell_check_file (
412405 x ,
413406 spell_checker ,
@@ -421,7 +414,7 @@ def main():
421414 # f is a file
422415 if exclude_check (f , args .exclude ) or skip_check (f , args .skip ):
423416 if not args .miss :
424- print ("\n Excluding" , x )
417+ print (f "\n Excluding { x } " )
425418 continue
426419
427420 # f is a file, so spell check it
@@ -444,21 +437,21 @@ def main():
444437
445438 for misspelled_word , found_file , line_num in bad_words :
446439 if misspelled_word != previous_word :
447- print ("\n " , misspelled_word , ":" , sep = " " )
440+ print (f "\n { misspelled_word } : " )
448441
449442 if (misspelled_word == previous_word ) and args .first :
450443 sys .stderr .write ("." )
451444 continue
452445
453446 if args .vim :
454- print (" vim +" , line_num , " " , found_file , sep = " " , file = sys .stderr )
447+ print (f " vim +{ line_num } { found_file } " , file = sys .stderr )
455448 else :
456- print (" " , found_file , ", " , line_num , sep = " " , file = sys .stderr )
449+ print (f " { found_file } , { line_num } " , file = sys .stderr )
457450
458451 previous_word = misspelled_word
459452
460453 print ("" )
461- print (len (bad_words ), " misspellings found" )
454+ print (f" { len (bad_words )} misspellings found" )
462455
463456 sys .exit (len (bad_words ))
464457
0 commit comments