diff --git a/codespell_lib/spellchecker.py b/codespell_lib/spellchecker.py index f1ad6885b6c..ac43074798f 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): @@ -177,6 +180,8 @@ def __init__(self) -> None: self.ignore_words_cased: Container[str] = frozenset() 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(