Skip to content
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/8464.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Following a deprecation period, ``ColorizedTextReporter`` only accepts ``ColorMappingDict``.

Refs #8464
26 changes: 2 additions & 24 deletions pylint/reporters/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
import sys
import warnings
from dataclasses import asdict, fields
from typing import TYPE_CHECKING, Dict, NamedTuple, Optional, TextIO, cast
from typing import TYPE_CHECKING, Dict, NamedTuple, TextIO

from pylint.message import Message
from pylint.reporters import BaseReporter
from pylint.reporters.ureports.text_writer import TextWriter
from pylint.utils import _splitstrip

if TYPE_CHECKING:
from pylint.lint import PyLinter
Expand Down Expand Up @@ -221,30 +220,9 @@ class ColorizedTextReporter(TextReporter):
def __init__(
self,
output: TextIO | None = None,
color_mapping: (
ColorMappingDict | dict[str, tuple[str | None, str]] | None
) = None,
color_mapping: ColorMappingDict | None = None,
) -> None:
super().__init__(output)
# TODO: 3.0: Remove deprecated typing and only accept ColorMappingDict as
# color_mapping parameter
if color_mapping and not isinstance(
list(color_mapping.values())[0], MessageStyle
):
warnings.warn(
"In pylint 3.0, the ColorizedTextReporter will only accept ColorMappingDict as "
"color_mapping parameter",
DeprecationWarning,
stacklevel=2,
)
temp_color_mapping: ColorMappingDict = {}
for key, value in color_mapping.items():
color = value[0]
style_attrs = tuple(_splitstrip(value[1])) # type: ignore[arg-type]
temp_color_mapping[key] = MessageStyle(color, style_attrs)
color_mapping = temp_color_mapping
else:
color_mapping = cast(Optional[ColorMappingDict], color_mapping)
self.color_mapping = color_mapping or ColorizedTextReporter.COLOR_MAPPING
ansi_terms = ["xterm-16color", "xterm-256color"]
if os.environ.get("TERM") not in ansi_terms:
Expand Down