summaryrefslogtreecommitdiff
path: root/tests/utils
diff options
context:
space:
mode:
authorDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2021-09-04 18:52:55 +0200
committerGitHub <noreply@github.com>2021-09-04 18:52:55 +0200
commit25000863761220c1aa5db129e3cd41f5fe51b167 (patch)
treed211e4464a8aef25f969adffe7ba7cb6df8b8981 /tests/utils
parent6c818310fd0e2396b6333ad623da577bf84e361e (diff)
downloadpylint-git-25000863761220c1aa5db129e3cd41f5fe51b167.tar.gz
Add typing with `PyAnnotate` to `./tests` (#4950)
* Add mypy_extensions to requirement for ``NoReturn`` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/utils')
-rw-r--r--tests/utils/unittest_ast_walker.py15
-rw-r--r--tests/utils/unittest_utils.py4
2 files changed, 10 insertions, 9 deletions
diff --git a/tests/utils/unittest_ast_walker.py b/tests/utils/unittest_ast_walker.py
index 364b35a35..9d350830a 100644
--- a/tests/utils/unittest_ast_walker.py
+++ b/tests/utils/unittest_ast_walker.py
@@ -2,6 +2,7 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
import warnings
+from typing import Dict, Set
import astroid
@@ -11,15 +12,15 @@ from pylint.utils import ASTWalker
class TestASTWalker:
class MockLinter:
- def __init__(self, msgs):
+ def __init__(self, msgs: Dict[str, bool]) -> None:
self._msgs = msgs
- def is_message_enabled(self, msgid):
+ def is_message_enabled(self, msgid: str) -> bool:
return self._msgs.get(msgid, True)
class Checker:
- def __init__(self):
- self.called = set()
+ def __init__(self) -> None:
+ self.called: Set[str] = set()
@check_messages("first-message")
def visit_module(self, module): # pylint: disable=unused-argument
@@ -37,7 +38,7 @@ class TestASTWalker:
def leave_assignname(self, module):
raise NotImplementedError
- def test_check_messages(self):
+ def test_check_messages(self) -> None:
linter = self.MockLinter(
{"first-message": True, "second-message": False, "third-message": True}
)
@@ -47,9 +48,9 @@ class TestASTWalker:
walker.walk(astroid.parse("x = func()"))
assert {"module", "assignname"} == checker.called
- def test_deprecated_methods(self):
+ def test_deprecated_methods(self) -> None:
class Checker:
- def __init__(self):
+ def __init__(self) -> None:
self.called = False
@check_messages("first-message")
diff --git a/tests/utils/unittest_utils.py b/tests/utils/unittest_utils.py
index a07a70c79..77853b234 100644
--- a/tests/utils/unittest_utils.py
+++ b/tests/utils/unittest_utils.py
@@ -23,7 +23,7 @@ import io
from pylint.utils import utils
-def test_decoding_stream_unknown_encoding():
+def test_decoding_stream_unknown_encoding() -> None:
"""decoding_stream should fall back to *some* decoding when given an
unknown encoding.
"""
@@ -34,7 +34,7 @@ def test_decoding_stream_unknown_encoding():
assert ret == ["foo\n", "bar"]
-def test_decoding_stream_known_encoding():
+def test_decoding_stream_known_encoding() -> None:
binary_io = io.BytesIO("€".encode("cp1252"))
stream = utils.decoding_stream(binary_io, "cp1252")
assert stream.read() == "€"