Skip to content

Commit f8064a3

Browse files
author
Anis Da Silva Campos
committed
Support pylint v3
in pylint v3.0.0, there is pylint-dev/pylint#8404, that breaks the current implementation of: - ClassAttrLoader - FixtureChecker This fix is an attempt of supporting both pylint v2 and v3
1 parent fc8fa90 commit f8064a3

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

pylint_pytest/checkers/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
import pylint
12
from pylint.checkers import BaseChecker
23

34

45
class BasePytestChecker(BaseChecker):
6+
if int(pylint.version.split(".")[0]) < 3:
7+
# Since https://github.com/pylint-dev/pylint/pull/8404, pylint does not need this
8+
# __implements__ pattern. keeping it for retro compatibility with pylint==2.x
9+
from pylint.interfaces import IAstroidChecker # pylint: disable=import-outside-toplevel
10+
11+
__implements__ = IAstroidChecker
12+
513
name = "pylint-pytest"

pylint_pytest/checkers/class_attr_loader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from typing import Optional, Set
22

33
from astroid import Assign, Attribute, ClassDef, Name
4-
from pylint.interfaces import IAstroidChecker
54

65
from ..utils import _can_use_fixture, _is_class_autouse_fixture
76
from . import BasePytestChecker
87

98

109
class ClassAttrLoader(BasePytestChecker):
11-
__implements__ = IAstroidChecker
1210
msgs = {"E6400": ("", "pytest-class-attr-loader", "")}
1311

1412
in_setup = False

pylint_pytest/checkers/fixture.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import pylint
99
import pytest
1010
from pylint.checkers.variables import VariablesChecker
11-
from pylint.interfaces import IAstroidChecker
1211

1312
from ..utils import (
1413
_can_use_fixture,
@@ -42,7 +41,6 @@ def pytest_collectreport(self, report):
4241

4342

4443
class FixtureChecker(BasePytestChecker):
45-
__implements__ = IAstroidChecker
4644
msgs = {
4745
"W6401": (
4846
"Using a deprecated @pytest.yield_fixture decorator",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
long_description_content_type="text/markdown",
2929
packages=find_packages(exclude=["tests*", "sandbox"]),
3030
install_requires=[
31-
"pylint<3",
31+
"pylint>=2",
3232
"pytest>=4.6",
3333
],
3434
python_requires=">=3.6",

tox.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
[tox]
2-
envlist = py36,py37,py38,py39,py310,py311
2+
envlist =
3+
py36-pylint2
4+
py37-pylint2
5+
py38-pylint{2,3}
6+
py39-pylint{2,3}
7+
py310-pylint{2,3}
8+
py311-pylint{2,3}
39
skipsdist = True
410
passenv =
511
FORCE_COLOR
@@ -8,6 +14,8 @@ passenv =
814
deps =
915
pytest
1016
pytest-cov
17+
pylint2: pylint>2,<3
18+
pylint3: pylint>3,<4
1119
commands =
1220
pip install --upgrade --editable .
1321
pytest --cov --cov-append {env:PYTEST_CI_ARGS:} {tty:--color=yes} {posargs:tests}

0 commit comments

Comments
 (0)