summaryrefslogtreecommitdiff
path: root/tests/test_self.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-09-17 18:28:28 +0200
committerGitHub <noreply@github.com>2021-09-17 18:28:28 +0200
commit096b31f109c1ee34c668f7ffe271c6493c889b80 (patch)
treeb04e0cb1123bc8f5af4a820284a6bb7df21f3662 /tests/test_self.py
parenta2e531246adc07121ca0f244c97d77a3ccf72c1f (diff)
downloadpylint-git-096b31f109c1ee34c668f7ffe271c6493c889b80.tar.gz
Add typing to `BaseReporter.out` (#5023)
* Add typing to `BaseReporter.out` * Add DeprecationWarning to `set_output` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/test_self.py')
-rw-r--r--tests/test_self.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/test_self.py b/tests/test_self.py
index 39b3965d4..2b5daef84 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -51,12 +51,11 @@ from copy import copy
from io import StringIO
from os.path import abspath, dirname, join
from pathlib import Path
-from typing import TYPE_CHECKING, Any, Generator, Iterator, List, Optional, Union
+from typing import TYPE_CHECKING, Any, Generator, Iterator, List, Optional, TextIO
from unittest import mock
from unittest.mock import patch
import pytest
-from _pytest.capture import EncodedFile
from py._path.local import LocalPath # type: ignore
from pylint import modify_sys_path
@@ -79,7 +78,7 @@ UNNECESSARY_LAMBDA = join(
@contextlib.contextmanager
-def _patch_streams(out: Union[StringIO, EncodedFile]) -> Iterator:
+def _patch_streams(out: TextIO) -> Iterator:
sys.stderr = sys.stdout = out
try:
yield
@@ -122,11 +121,11 @@ class MultiReporter(BaseReporter):
pass
@property
- def out(self) -> StringIO:
+ def out(self) -> TextIO: # type: ignore[override]
return self._reporters[0].out
- @property
- def linter(self) -> Optional[Any]:
+ @property # type: ignore[override]
+ def linter(self) -> PyLinter: # type: ignore[override]
return self._linter
@linter.setter
@@ -159,9 +158,7 @@ class TestRunTC:
assert pylint_code == code, msg
@staticmethod
- def _run_pylint(
- args: List[str], out: Union[StringIO, EncodedFile], reporter: Any = None
- ) -> int:
+ def _run_pylint(args: List[str], out: TextIO, reporter: Any = None) -> int:
args = args + ["--persistent=no"]
with _patch_streams(out):
with pytest.raises(SystemExit) as cm: