Skip to content

Commit

Permalink
Misc cleanup after dropping Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls authored and Pierre-Sassoulas committed Jun 23, 2023
1 parent 8a621be commit b9ed113
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
1 change: 0 additions & 1 deletion pylint/config/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pylint import utils as pylint_utils
from pylint.config.callback_actions import _CallbackAction
from pylint.config.deprecation_actions import _NewNamesAction, _OldNamesAction
from pylint.constants import PY38_PLUS

_ArgumentTypes = Union[
str,
Expand Down
4 changes: 2 additions & 2 deletions pylint/testutils/checker_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from astroid import nodes

from pylint.constants import IS_PYPY, PY38_PLUS, PY39_PLUS
from pylint.constants import IS_PYPY, PY39_PLUS
from pylint.testutils.global_test_linter import linter
from pylint.testutils.output_line import MessageTest
from pylint.testutils.unittest_linter import UnittestLinter
Expand Down Expand Up @@ -76,7 +76,7 @@ def assertAddsMessages(

assert expected_msg.line == gotten_msg.line, msg
assert expected_msg.col_offset == gotten_msg.col_offset, msg
if PY38_PLUS and not IS_PYPY or PY39_PLUS:
if not IS_PYPY or PY39_PLUS:
assert expected_msg.end_line == gotten_msg.end_line, msg
assert expected_msg.end_col_offset == gotten_msg.end_col_offset, msg

Expand Down
9 changes: 1 addition & 8 deletions pylint/testutils/output_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from astroid import nodes

from pylint.constants import PY38_PLUS
from pylint.interfaces import UNDEFINED, Confidence
from pylint.message.message import Message

Expand Down Expand Up @@ -60,13 +59,7 @@ def from_msg(cls, msg: Message, check_endline: bool = True) -> OutputLine:

@staticmethod
def _get_column(column: str | int) -> int:
"""Handle column numbers except for python < 3.8.
The ast parser in those versions doesn't return them.
"""
if not PY38_PLUS:
# We check the column only for the new better ast parser introduced in python 3.8
return 0 # pragma: no cover
"""Handle column numbers."""
return int(column)

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions tests/testutils/test_lint_module_output_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import pytest

from pylint.constants import IS_PYPY, PY38_PLUS, PY39_PLUS
from pylint.constants import IS_PYPY, PY39_PLUS
from pylint.testutils import FunctionalTestFile, LintModuleTest
from pylint.testutils.functional import LintModuleOutputUpdate

Expand Down Expand Up @@ -73,7 +73,7 @@ def test_lint_module_output_update_remove_useless_txt(


@pytest.mark.skipif(
not PY38_PLUS or (IS_PYPY and not PY39_PLUS),
IS_PYPY and not PY39_PLUS,
reason="Requires accurate 'end_col' value to update output",
)
@pytest.mark.parametrize(
Expand Down
22 changes: 8 additions & 14 deletions tests/testutils/test_output_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import pytest

from pylint.constants import PY38_PLUS
from pylint.interfaces import HIGH, INFERENCE, Confidence
from pylint.message import Message
from pylint.testutils.output_line import OutputLine
Expand Down Expand Up @@ -62,12 +61,10 @@ def test_output_line() -> None:

def test_output_line_from_message(message: _MessageCallable) -> None:
"""Test that the OutputLine NamedTuple is instantiated correctly with from_msg."""
expected_column = 2 if PY38_PLUS else 0

output_line = OutputLine.from_msg(message())
assert output_line.symbol == "missing-docstring"
assert output_line.lineno == 1
assert output_line.column == expected_column
assert output_line.column == 2
assert output_line.end_lineno == 1
assert output_line.end_column == 3
assert output_line.object == "obj"
Expand All @@ -77,7 +74,7 @@ def test_output_line_from_message(message: _MessageCallable) -> None:
output_line_with_end = OutputLine.from_msg(message(), True)
assert output_line_with_end.symbol == "missing-docstring"
assert output_line_with_end.lineno == 1
assert output_line_with_end.column == expected_column
assert output_line_with_end.column == 2
assert output_line_with_end.end_lineno == 1
assert output_line_with_end.end_column == 3
assert output_line_with_end.object == "obj"
Expand All @@ -87,7 +84,7 @@ def test_output_line_from_message(message: _MessageCallable) -> None:
output_line_without_end = OutputLine.from_msg(message(), False)
assert output_line_without_end.symbol == "missing-docstring"
assert output_line_without_end.lineno == 1
assert output_line_without_end.column == expected_column
assert output_line_without_end.column == 2
assert output_line_without_end.end_lineno is None
assert output_line_without_end.end_column is None
assert output_line_without_end.object == "obj"
Expand All @@ -102,11 +99,10 @@ def test_output_line_to_csv(confidence: Confidence, message: _MessageCallable) -
"""
output_line = OutputLine.from_msg(message(confidence), True)
csv = output_line.to_csv()
expected_column = "2" if PY38_PLUS else "0"
assert csv == (
"missing-docstring",
"1",
expected_column,
"2",
"1",
"3",
"obj",
Expand All @@ -116,11 +112,10 @@ def test_output_line_to_csv(confidence: Confidence, message: _MessageCallable) -

output_line_without_end = OutputLine.from_msg(message(confidence), False)
csv = output_line_without_end.to_csv()
expected_column = "2" if PY38_PLUS else "0"
assert csv == (
"missing-docstring",
"1",
expected_column,
"2",
"None",
"None",
"obj",
Expand All @@ -134,13 +129,12 @@ def test_output_line_from_csv() -> None:
Test OutputLine of length 8.
"""
proper_csv = ["missing-docstring", "1", "2", "1", "None", "obj", "msg", "HIGH"]
expected_column = 2 if PY38_PLUS else 0

output_line = OutputLine.from_csv(proper_csv)
assert output_line == OutputLine(
symbol="missing-docstring",
lineno=1,
column=expected_column,
column=2,
end_lineno=1,
end_column=None,
object="obj",
Expand All @@ -151,7 +145,7 @@ def test_output_line_from_csv() -> None:
assert output_line_with_end == OutputLine(
symbol="missing-docstring",
lineno=1,
column=expected_column,
column=2,
end_lineno=1,
end_column=None,
object="obj",
Expand All @@ -162,7 +156,7 @@ def test_output_line_from_csv() -> None:
assert output_line_without_end == OutputLine(
symbol="missing-docstring",
lineno=1,
column=expected_column,
column=2,
end_lineno=None,
end_column=None,
object="obj",
Expand Down

0 comments on commit b9ed113

Please sign in to comment.