From 44180da558453da6d1b2d8d8de7665d479aaedb6 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 8 Mar 2023 22:41:20 +0100 Subject: [Reporter] Remove 'set_output' in favor of reporter.out --- doc/whatsnew/fragments/8408.breaking | 3 +++ pylint/reporters/base_reporter.py | 11 ----------- tests/reporters/unittest_reporting.py | 12 ------------ 3 files changed, 3 insertions(+), 23 deletions(-) create mode 100644 doc/whatsnew/fragments/8408.breaking 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") -- cgit v1.2.1