Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reporter] Remove 'set_output' in favor of reporter.out #8408

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/8408.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'Reporter.set_output' was removed in favor of 'reporter.out = stream'.

Refs #8408
11 changes: 0 additions & 11 deletions pylint/reporters/base_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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
Expand Down Expand Up @@ -41,16 +40,6 @@ def handle_message(self, msg: Message) -> None:
"""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)
Expand Down
12 changes: 0 additions & 12 deletions tests/reporters/unittest_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from __future__ import annotations

import sys
import warnings
from contextlib import redirect_stdout
from io import StringIO
Expand All @@ -15,7 +14,6 @@
from typing import TYPE_CHECKING, TextIO

import pytest
from _pytest.recwarn import WarningsRecorder

from pylint import checkers
from pylint.interfaces import HIGH
Expand Down Expand Up @@ -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")
Expand Down