diff options
| author | Eli Fine <eli88fine@gmail.com> | 2022-05-06 04:10:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-06 10:10:07 +0200 |
| commit | ea4e69b5fd6a1b1dac366082a7bade88c4cfad80 (patch) | |
| tree | 793dd2a2dd1b6a48e00306a5bf370afe1a623b6d /tests/checkers | |
| parent | d6f636b675a8497f4ee64fbc15c8cc041a261d40 (diff) | |
| download | pylint-git-ea4e69b5fd6a1b1dac366082a7bade88c4cfad80.tar.gz | |
spellcheck will skip the rule names of mypy inline directives (#5929)
Co-authored-by: Eli Fine <eli.fine@resilience.com>
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'tests/checkers')
| -rw-r--r-- | tests/checkers/unittest_spelling.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/checkers/unittest_spelling.py b/tests/checkers/unittest_spelling.py index 9939ccb35..de1a95610 100644 --- a/tests/checkers/unittest_spelling.py +++ b/tests/checkers/unittest_spelling.py @@ -310,7 +310,7 @@ class TestSpellingChecker(CheckerTestCase): # pylint:disable=too-many-public-me ("noqa", ":", "flake8 / zimports directive"), ("nosec", "", "bandit directive"), ("isort", ":skip", "isort directive"), - ("mypy", ":", "mypy directive"), + ("mypy", ":", "mypy top of file directive"), ), ) def test_skip_tool_directives_at_beginning_of_comments_but_still_raise_error_if_directive_appears_later_in_comment( # pylint:disable=unused-argument @@ -374,6 +374,24 @@ 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): + 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", |
