diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 98696c0f5d..94ab65d068 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -54,7 +54,13 @@ uri_regex_def = ( r"(\b(?:https?|[ts]?ftp|file|git|smb)://[^\s]+(?=$|\s)|\b[\w.%+-]+@[\w.-]+\b)" ) -inline_ignore_regex = re.compile(r"[^\w\s]\s*codespell:ignore\b(\s+(?P[\w,]*))?") +codespell_ignore_tag = "codespell:ignore" +inline_ignore_regex = re.compile( + rf"[^\w\s]\s*{codespell_ignore_tag}\b(\s+(?P[\w,]*))?" +) +USAGE = """ +\t%prog [OPTIONS] [file1 file2 ... fileN] +""" supported_languages_en = ("en", "en_GB", "en_US", "en_CA", "en_AU") supported_languages = supported_languages_en @@ -904,7 +910,9 @@ def parse_lines( line_number = fragment_line_number + i extra_words_to_ignore = set() - match = inline_ignore_regex.search(line) + match = ( + inline_ignore_regex.search(line) if codespell_ignore_tag in line else None + ) if match: extra_words_to_ignore = set( filter(None, (match.group("words") or "").split(","))