summaryrefslogtreecommitdiff
path: root/pylint/testutils/output_line.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/testutils/output_line.py')
-rw-r--r--pylint/testutils/output_line.py70
1 files changed, 15 insertions, 55 deletions
diff --git a/pylint/testutils/output_line.py b/pylint/testutils/output_line.py
index 7465fce9d..95f24cc12 100644
--- a/pylint/testutils/output_line.py
+++ b/pylint/testutils/output_line.py
@@ -1,10 +1,9 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
-import warnings
from collections.abc import Sequence
from typing import Any, NamedTuple, TypeVar
@@ -13,7 +12,6 @@ from astroid import nodes
from pylint.constants import PY38_PLUS
from pylint.interfaces import UNDEFINED, Confidence
from pylint.message.message import Message
-from pylint.testutils.constants import UPDATE_OPTION
_T = TypeVar("_T")
@@ -89,60 +87,22 @@ class OutputLine(NamedTuple):
"""
if isinstance(row, str):
row = row.split(",")
- # noinspection PyBroadException
- # pylint: disable = too-many-try-statements
try:
+ line = int(row[1])
column = cls._get_column(row[2])
- if len(row) == 5:
- warnings.warn(
- "In pylint 3.0 functional tests expected output should always include the "
- "expected confidence level, expected end_line and expected end_column. "
- "An OutputLine should thus have a length of 8.",
- DeprecationWarning,
- stacklevel=2,
- )
- return cls(
- row[0],
- int(row[1]),
- column,
- None,
- None,
- row[3],
- row[4],
- UNDEFINED.name,
- )
- if len(row) == 6:
- warnings.warn(
- "In pylint 3.0 functional tests expected output should always include the "
- "expected end_line and expected end_column. An OutputLine should thus have "
- "a length of 8.",
- DeprecationWarning,
- stacklevel=2,
- )
- return cls(
- row[0], int(row[1]), column, None, None, row[3], row[4], row[5]
- )
- if len(row) == 8:
- end_line = cls._get_py38_none_value(row[3], check_endline)
- end_column = cls._get_py38_none_value(row[4], check_endline)
- return cls(
- row[0],
- int(row[1]),
- column,
- cls._value_to_optional_int(end_line),
- cls._value_to_optional_int(end_column),
- row[5],
- row[6],
- row[7],
- )
- raise IndexError
- except Exception: # pylint: disable=broad-except
- warnings.warn(
- "Expected 'msg-symbolic-name:42:27:MyClass.my_function:The message:"
- f"CONFIDENCE' but we got '{':'.join(row)}'. Try updating the expected"
- f" output with:\npython tests/test_functional.py {UPDATE_OPTION}",
- UserWarning,
+ end_line = cls._value_to_optional_int(
+ cls._get_py38_none_value(row[3], check_endline)
+ )
+ end_column = cls._value_to_optional_int(
+ cls._get_py38_none_value(row[4], check_endline)
)
+ # symbol, line, column, end_line, end_column, node, msg, confidences
+ assert len(row) == 8
+ return cls(
+ row[0], line, column, end_line, end_column, row[5], row[6], row[7]
+ )
+ except Exception: # pylint: disable=broad-except
+ # We need this to not fail for the update script to work.
return cls("", 0, 0, None, None, "", "", "")
def to_csv(self) -> tuple[str, str, str, str, str, str, str, str]: