summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-03-08 22:41:20 +0100
committerDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2023-03-08 23:02:17 +0100
commit44180da558453da6d1b2d8d8de7665d479aaedb6 (patch)
tree67f907d1350ad7f0134f6bb04b84f2587c6493fa
parent358264aaf622505f6d2e8bc699618382981a078c (diff)
downloadpylint-git-44180da558453da6d1b2d8d8de7665d479aaedb6.tar.gz
[Reporter] Remove 'set_output' in favor of reporter.out
-rw-r--r--doc/whatsnew/fragments/8408.breaking3
-rw-r--r--pylint/reporters/base_reporter.py11
-rw-r--r--tests/reporters/unittest_reporting.py12
3 files changed, 3 insertions, 23 deletions
diff --git a/doc/whatsnew/fragments/8408.breaking b/doc/whatsnew/fragments/8408.breaking
new file mode 100644
index 000000000..697a7ee50
--- /dev/null
+++ b/doc/whatsnew/fragments/8408.breaking
@@ -0,0 +1,3 @@
+'Reporter.set_output' was removed in favor of 'reporter.out = stream'.
+
+Refs #8408
diff --git a/pylint/reporters/base_reporter.py b/pylint/reporters/base_reporter.py
index 5d4240723..518f2f2ae 100644
--- a/pylint/reporters/base_reporter.py
+++ b/pylint/reporters/base_reporter.py
@@ -7,7 +7,6 @@ from __future__ import annotations
import os
import sys
from typing import TYPE_CHECKING, TextIO
-from warnings import warn
from pylint.message import Message
from pylint.reporters.ureports.nodes import Text
@@ -41,16 +40,6 @@ class BaseReporter:
"""Handle a new message triggered on the current file."""
self.messages.append(msg)
- def set_output(self, output: TextIO | None = None) -> None:
- """Set output stream."""
- # TODO: 3.0: Remove deprecated method
- warn(
- "'set_output' will be removed in 3.0, please use 'reporter.out = stream' instead",
- DeprecationWarning,
- stacklevel=2,
- )
- self.out = output or sys.stdout
-
def writeln(self, string: str = "") -> None:
"""Write a line in the output buffer."""
print(string, file=self.out)
diff --git a/tests/reporters/unittest_reporting.py b/tests/reporters/unittest_reporting.py
index 40a18036a..4bc656640 100644
--- a/tests/reporters/unittest_reporting.py
+++ b/tests/reporters/unittest_reporting.py
@@ -6,7 +6,6 @@
from __future__ import annotations
-import sys
import warnings
from contextlib import redirect_stdout
from io import StringIO
@@ -15,7 +14,6 @@ from pathlib import Path
from typing import TYPE_CHECKING, TextIO
import pytest
-from _pytest.recwarn import WarningsRecorder
from pylint import checkers
from pylint.interfaces import HIGH
@@ -128,16 +126,6 @@ def test_template_option_with_header(linter: PyLinter) -> None:
assert out_lines[2] == '{ "Category": "convention" }'
-def test_deprecation_set_output(recwarn: WarningsRecorder) -> None:
- """TODO remove in 3.0."""
- reporter = BaseReporter()
- # noinspection PyDeprecation
- reporter.set_output(sys.stdout)
- warning = recwarn.pop()
- assert "set_output' will be removed in 3.0" in str(warning)
- assert reporter.out == sys.stdout
-
-
def test_parseable_output_deprecated() -> None:
with warnings.catch_warnings(record=True) as cm:
warnings.simplefilter("always")