Skip to content

Commit

Permalink
remove support of pylint v1
Browse files Browse the repository at this point in the history
not needed anymore now that we require >=v2
  • Loading branch information
anis-campos committed Dec 1, 2023
1 parent f8064a3 commit c8bbaeb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 24 deletions.
6 changes: 4 additions & 2 deletions pylint_pytest/checkers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import pylint
from pylint.checkers import BaseChecker

from pylint_pytest.utils import PYLINT_VERSION_MAJOR


class BasePytestChecker(BaseChecker):
if int(pylint.version.split(".")[0]) < 3:
if PYLINT_VERSION_MAJOR < 3:
# todo(maybe-remove): if we only support pylint>=3
# Since https://github.com/pylint-dev/pylint/pull/8404, pylint does not need this
# __implements__ pattern. keeping it for retro compatibility with pylint==2.x
from pylint.interfaces import IAstroidChecker # pylint: disable=import-outside-toplevel
Expand Down
9 changes: 1 addition & 8 deletions pylint_pytest/checkers/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Set, Tuple

import astroid
import pylint
import pytest
from pylint.checkers.variables import VariablesChecker

Expand Down Expand Up @@ -312,10 +311,4 @@ def patch_add_message(
):
return

if int(pylint.__version__.split(".")[0]) >= 2:
FixtureChecker._original_add_message(
self, msgid, line, node, args, confidence, col_offset
)
else:
# python2 + pylint1.9 backward compatibility
FixtureChecker._original_add_message(self, msgid, line, node, args, confidence)
FixtureChecker._original_add_message(self, msgid, line, node, args, confidence, col_offset)
3 changes: 3 additions & 0 deletions pylint_pytest/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import inspect

import astroid
import pylint

PYLINT_VERSION_MAJOR = int(pylint.__version__.split(".")[0])


def _is_pytest_mark_usefixtures(decorator):
Expand Down
10 changes: 2 additions & 8 deletions tests/base_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
from typing import Any, Dict, List

import astroid
from pylint.testutils import MessageTest, UnittestLinter

try:
from pylint.utils import ASTWalker
except ImportError:
# for pylint 1.9
from pylint.utils import PyLintASTWalker as ASTWalker

from pylint.checkers import BaseChecker
from pylint.testutils import MessageTest, UnittestLinter
from pylint.utils import ASTWalker

import pylint_pytest.checkers.fixture

Expand Down
7 changes: 1 addition & 6 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pylint
import pytest
from base_tester import BasePytestTester
from pylint.checkers.variables import VariablesChecker
Expand All @@ -18,9 +17,5 @@ def test_import_twice(self, enable_plugin):
"""catch a coding error when using fixture + if + inline import"""
self.run_linter(enable_plugin)

if int(pylint.__version__.split(".")[0]) < 2:
# for some reason pylint 1.9.5 does not raise unused-import for inline import
self.verify_messages(1, msg_id="unused-import")
else:
self.verify_messages(2, msg_id="unused-import")
self.verify_messages(2, msg_id="unused-import")
self.verify_messages(1, msg_id="redefined-outer-name")

0 comments on commit c8bbaeb

Please sign in to comment.