summaryrefslogtreecommitdiff
path: root/pylint/checkers/spelling.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/checkers/spelling.py')
-rw-r--r--pylint/checkers/spelling.py23
1 files changed, 4 insertions, 19 deletions
diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py
index 61229ddca..274fc7599 100644
--- a/pylint/checkers/spelling.py
+++ b/pylint/checkers/spelling.py
@@ -172,7 +172,6 @@ class ForwardSlashChunker(Chunker): # type: ignore[misc]
CODE_FLANKED_IN_BACKTICK_REGEX = re.compile(r"(\s|^)(`{1,2})([^`]+)(\2)([^`]|$)")
-MYPY_IGNORE_DIRECTIVE_RULE_REGEX = re.compile(r"(\s|^)(type\: ignore\[[^\]]+\])(.*)")
def _strip_code_flanked_in_backticks(line: str) -> str:
@@ -190,23 +189,6 @@ def _strip_code_flanked_in_backticks(line: str) -> str:
)
-def _strip_mypy_ignore_directive_rule(line: str) -> str:
- """Alter line so mypy rule name is ignored.
-
- Pyenchant parses anything flanked by spaces as an individual token,
- so this cannot be done at the individual filter level.
- """
-
- def replace_rule_name_but_leave_surrounding_characters(
- match_obj: re.Match[str],
- ) -> str:
- return match_obj.group(1) + match_obj.group(3)
-
- return MYPY_IGNORE_DIRECTIVE_RULE_REGEX.sub(
- replace_rule_name_but_leave_surrounding_characters, line
- )
-
-
class SpellingChecker(BaseTokenChecker):
"""Check spelling in comments and docstrings."""
@@ -362,7 +344,6 @@ class SpellingChecker(BaseTokenChecker):
starts_with_comment = False
line = _strip_code_flanked_in_backticks(line)
- line = _strip_mypy_ignore_directive_rule(line)
for word, word_start_at in self.tokenizer(line.strip()):
word_start_at += initial_space
@@ -436,6 +417,10 @@ class SpellingChecker(BaseTokenChecker):
if token.startswith("# pylint:"):
# Skip pylint enable/disable comments
continue
+ if token.startswith("# type: "):
+ # Skip python 2 type comments and mypy type ignore comments
+ # mypy do not support additional text in type comments
+ continue
self._check_spelling("wrong-spelling-in-comment", token, start_row)
@only_required_for_messages("wrong-spelling-in-docstring")