Skip to content

Commit

Permalink
Support pylint v3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Anis Da Silva Campos committed Dec 1, 2023
1 parent fc8fa90 commit f8064a3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pylint_pytest/checkers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import pylint
from pylint.checkers import BaseChecker


class BasePytestChecker(BaseChecker):
if int(pylint.version.split(".")[0]) < 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

__implements__ = IAstroidChecker

name = "pylint-pytest"
2 changes: 0 additions & 2 deletions pylint_pytest/checkers/class_attr_loader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from typing import Optional, Set

from astroid import Assign, Attribute, ClassDef, Name
from pylint.interfaces import IAstroidChecker

from ..utils import _can_use_fixture, _is_class_autouse_fixture
from . import BasePytestChecker


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

in_setup = False
Expand Down
2 changes: 0 additions & 2 deletions pylint_pytest/checkers/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import pylint
import pytest
from pylint.checkers.variables import VariablesChecker
from pylint.interfaces import IAstroidChecker

from ..utils import (
_can_use_fixture,
Expand Down Expand Up @@ -42,7 +41,6 @@ def pytest_collectreport(self, report):


class FixtureChecker(BasePytestChecker):
__implements__ = IAstroidChecker
msgs = {
"W6401": (
"Using a deprecated @pytest.yield_fixture decorator",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
long_description_content_type="text/markdown",
packages=find_packages(exclude=["tests*", "sandbox"]),
install_requires=[
"pylint<3",
"pylint>=2",
"pytest>=4.6",
],
python_requires=">=3.6",
Expand Down
10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[tox]
envlist = py36,py37,py38,py39,py310,py311
envlist =
py36-pylint2
py37-pylint2
py38-pylint{2,3}
py39-pylint{2,3}
py310-pylint{2,3}
py311-pylint{2,3}
skipsdist = True
passenv =
FORCE_COLOR
Expand All @@ -8,6 +14,8 @@ passenv =
deps =
pytest
pytest-cov
pylint2: pylint>2,<3
pylint3: pylint>3,<4
commands =
pip install --upgrade --editable .
pytest --cov --cov-append {env:PYTEST_CI_ARGS:} {tty:--color=yes} {posargs:tests}

0 comments on commit f8064a3

Please sign in to comment.