@@ -617,24 +617,23 @@ def parse_options(
617617
618618
619619def parse_ignore_words_option (ignore_words_option : List [str ]) -> Set [str ]:
620- ignore_words = set ()
620+ ignore_words : Set [ str ] = set ()
621621 if ignore_words_option :
622622 for comma_separated_words in ignore_words_option :
623- for word in comma_separated_words .split ("," ):
624- ignore_words .add (word .strip ())
623+ ignore_words .update (
624+ word .strip () for word in comma_separated_words .split ("," )
625+ )
625626 return ignore_words
626627
627628
628629def build_exclude_hashes (filename : str , exclude_lines : Set [str ]) -> None :
629630 with open (filename , encoding = "utf-8" ) as f :
630- for line in f :
631- exclude_lines .add (line .rstrip ())
631+ exclude_lines .update (line .rstrip () for line in f )
632632
633633
634634def build_ignore_words (filename : str , ignore_words : Set [str ]) -> None :
635635 with open (filename , encoding = "utf-8" ) as f :
636- for line in f :
637- ignore_words .add (line .strip ())
636+ ignore_words .update (line .strip () for line in f )
638637
639638
640639def add_misspelling (
@@ -811,7 +810,7 @@ def apply_uri_ignore_words(
811810) -> List [Match [str ]]:
812811 if not uri_ignore_words :
813812 return check_matches
814- for uri in re .findall (uri_regex , line ):
813+ for uri in uri_regex .findall (line ):
815814 for uri_word in extract_words (uri , word_regex , ignore_word_regex ):
816815 if uri_word in uri_ignore_words :
817816 # determine/remove only the first among matches
@@ -1097,7 +1096,7 @@ def main(*args: str) -> int:
10971096 return EX_USAGE
10981097 uri_ignore_words = parse_ignore_words_option (options .uri_ignore_words_list )
10991098
1100- dictionaries = options .dictionary if options . dictionary else ["-" ]
1099+ dictionaries = options .dictionary or ["-" ]
11011100
11021101 use_dictionaries = []
11031102 for dictionary in dictionaries :
@@ -1186,7 +1185,7 @@ def main(*args: str) -> int:
11861185 if os .path .isdir (filename ):
11871186 for root , dirs , files in os .walk (filename ):
11881187 if glob_match .match (root ): # skip (absolute) directories
1189- del dirs [:]
1188+ dirs . clear ()
11901189 continue
11911190 if is_hidden (root , options .check_hidden ): # dir itself hidden
11921191 continue
0 commit comments