diff --git a/codespell_lib/spellchecker.py b/codespell_lib/spellchecker.py index aa39e43b523..9ba05611fa4 100644 --- a/codespell_lib/spellchecker.py +++ b/codespell_lib/spellchecker.py @@ -109,7 +109,10 @@ _builtin_default_as_tuple = tuple(_builtin_default.split(",")) -_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,]*))?" +) class UnknownBuiltinDictionaryError(ValueError): @@ -210,6 +213,8 @@ def __init__( self.load_builtin_dictionaries(builtin_dictionaries) def _parse_inline_ignore(self, line: str) -> Optional[FrozenSet[str]]: + if _codespell_ignore_tag not in line: + return frozenset() inline_ignore_match = _inline_ignore_regex.search(line) if inline_ignore_match: words = frozenset(