summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-03-02 21:18:40 +0100
committerGitHub <noreply@github.com>2023-03-02 21:18:40 +0100
commitb5aab35a6f20efad94ae8da07392fad6d1c28aad (patch)
tree10ad12004fc030e4adc99cd0f65d87499b6957cb /tests
parent5337e6280e76e13d1922b03ffeba7887a00e6356 (diff)
downloadpylint-git-b5aab35a6f20efad94ae8da07392fad6d1c28aad.tar.gz
[spelling] Ignore spelling in type/mypy type ignore comments (#8370)
enchant does not understand class name well enough so it creates false positives, and mypy type ignore comments with additional text are a syntax error anyway, so raising a spelling mistakes for it is not really important.
Diffstat (limited to 'tests')
-rw-r--r--tests/checkers/unittest_spelling.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/tests/checkers/unittest_spelling.py b/tests/checkers/unittest_spelling.py
index d716def60..b02cf73a8 100644
--- a/tests/checkers/unittest_spelling.py
+++ b/tests/checkers/unittest_spelling.py
@@ -260,6 +260,27 @@ class TestSpellingChecker(CheckerTestCase): # pylint:disable=too-many-public-me
@skip_on_missing_package_or_dict
@set_config(spelling_dict=spell_dict)
+ @pytest.mark.parametrize(
+ "type_comment",
+ [
+ "# type: (NotAWord) -> NotAWord",
+ "# type: List[NotAWord] -> List[NotAWord]",
+ "# type: Dict[NotAWord] -> Dict[NotAWord]",
+ "# type: NotAWord",
+ "# type: List[NotAWord]",
+ "# type: Dict[NotAWord]",
+ "# type: ImmutableList[Manager]",
+ # will result in error: Invalid "type: ignore" comment [syntax]
+ # when analyzed with mypy 1.02
+ "# type: ignore[attr-defined] NotAWord",
+ ],
+ )
+ def test_skip_type_comments(self, type_comment: str) -> None:
+ self.checker.process_tokens(_tokenize_str(type_comment))
+ assert not self.linter.release_messages()
+
+ @skip_on_missing_package_or_dict
+ @set_config(spelling_dict=spell_dict)
def test_skip_sphinx_directives(self) -> None:
stmt = astroid.extract_node(
'class ComentAbc(object):\n """This is :class:`ComentAbc` with a bad coment"""\n pass'
@@ -364,24 +385,6 @@ class TestSpellingChecker(CheckerTestCase): # pylint:disable=too-many-public-me
self.checker.process_tokens(_tokenize_str(full_comment))
@skip_on_missing_package_or_dict
- @set_config(spelling_dict=spell_dict)
- def test_skip_mypy_ignore_directives(self) -> None:
- full_comment = "# type: ignore[attr-defined] attr"
- with self.assertAddsMessages(
- MessageTest(
- "wrong-spelling-in-comment",
- line=1,
- args=(
- "attr",
- full_comment,
- " ^^^^",
- self._get_msg_suggestions("attr"),
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str(full_comment))
-
- @skip_on_missing_package_or_dict
@set_config(
spelling_dict=spell_dict,
spelling_ignore_comment_directives="newdirective:,noqa",