Skip to content

Commit f6e9b9e

Browse files
committed
Merge branch 'master' into drop-eol-python-add-3.12
* master: Update/Prepare Changelog for v1.1.7 use pylint v3 in the repo remove support of pylint v1 Support pylint v3 Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com> Additionally, some minor format modifications at `CHANGELOG.md`
2 parents 65fa52b + 48212e2 commit f6e9b9e

File tree

10 files changed

+44
-40
lines changed

10 files changed

+44
-40
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44

55
### Removed
66

7-
- Support for Python 3.6 & 3.7 (#23)
7+
* Support for Python 3.6 & 3.7 (https://github.com/pylint-dev/pylint-pytest/pull/23)
8+
9+
## [1.1.7] - 2023-12-04
10+
11+
This is a small release to support additionally Pylint v3.
12+
It should be noted, however, that for linting, Pylint must be v3 or newer (due to backwards-incompatible changes).
13+
14+
### Fixed
15+
16+
* Support pylint v3 and drop v1 (https://github.com/pylint-dev/pylint-pytest/pull/27)
817

918
## [1.1.6] - 2023-11-20
1019

pylint_pytest/checkers/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
from pylint.checkers import BaseChecker
22

3+
from pylint_pytest.utils import PYLINT_VERSION_MAJOR
4+
35

46
class BasePytestChecker(BaseChecker):
7+
if PYLINT_VERSION_MAJOR < 3:
8+
# todo(maybe-remove): if we only support pylint>=3
9+
# Since https://github.com/pylint-dev/pylint/pull/8404, pylint does not need this
10+
# __implements__ pattern. keeping it for retro compatibility with pylint==2.x
11+
# pylint: disable=import-outside-toplevel,no-name-in-module
12+
from pylint.interfaces import IAstroidChecker
13+
14+
__implements__ = IAstroidChecker
15+
516
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: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
from typing import Set, Tuple
66

77
import astroid
8-
import pylint
98
import pytest
109
from pylint.checkers.variables import VariablesChecker
11-
from pylint.interfaces import IAstroidChecker
1210

1311
from ..utils import (
1412
_can_use_fixture,
@@ -42,7 +40,6 @@ def pytest_collectreport(self, report):
4240

4341

4442
class FixtureChecker(BasePytestChecker):
45-
__implements__ = IAstroidChecker
4643
msgs = {
4744
"W6401": (
4845
"Using a deprecated @pytest.yield_fixture decorator",
@@ -235,7 +232,7 @@ def visit_functiondef(self, node):
235232
for arg in node.args.args:
236233
self._invoked_with_func_args.add(arg.name)
237234

238-
# pylint: disable=bad-staticmethod-argument,too-many-branches # The function itself is an if-return logic.
235+
# pylint: disable=bad-staticmethod-argument # The function itself is an if-return logic.
239236
@staticmethod
240237
def patch_add_message(
241238
self, msgid, line=None, node=None, args=None, confidence=None, col_offset=None
@@ -314,10 +311,4 @@ def patch_add_message(
314311
):
315312
return
316313

317-
if int(pylint.__version__.split(".")[0]) >= 2:
318-
FixtureChecker._original_add_message(
319-
self, msgid, line, node, args, confidence, col_offset
320-
)
321-
else:
322-
# python2 + pylint1.9 backward compatibility
323-
FixtureChecker._original_add_message(self, msgid, line, node, args, confidence)
314+
FixtureChecker._original_add_message(self, msgid, line, node, args, confidence, col_offset)

pylint_pytest/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import inspect
22

33
import astroid
4+
import pylint
5+
6+
PYLINT_VERSION_MAJOR = int(pylint.__version__.split(".")[0])
47

58

69
def _is_pytest_mark_usefixtures(decorator):

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,11 @@ load-plugins= [
124124
"pylint.extensions.broad_try_clause",
125125
"pylint.extensions.check_elif",
126126
"pylint.extensions.code_style",
127-
"pylint.extensions.comparetozero",
128127
"pylint.extensions.comparison_placement",
129128
"pylint.extensions.confusing_elif",
130129
# "pylint.extensions.consider_ternary_expression", # Not a pretty refactoring
131130
"pylint.extensions.docparams",
132131
"pylint.extensions.docstyle",
133-
"pylint.extensions.emptystring",
134132
"pylint.extensions.eq_without_hash",
135133
"pylint.extensions.for_any_all",
136134
"pylint.extensions.mccabe",
@@ -175,4 +173,8 @@ output-format = "colorized"
175173
ignored-argument-names = "_.*"
176174

177175
[tool.pylint."messages control"]
178-
enable = ["useless-suppression"]
176+
enable = [
177+
"useless-suppression",
178+
"use-implicit-booleaness-not-comparison-to-zero",
179+
"use-implicit-booleaness-not-comparison-to-string",
180+
]

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.8",

tests/base_tester.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
from abc import ABC
44
from pathlib import Path
55
from pprint import pprint
6-
from typing import Any, Dict, List
6+
from typing import List, Type
77

88
import astroid
9-
from pylint.testutils import MessageTest, UnittestLinter
10-
11-
try:
12-
from pylint.utils import ASTWalker
13-
except ImportError:
14-
# for pylint 1.9
15-
from pylint.utils import PyLintASTWalker as ASTWalker
16-
179
from pylint.checkers import BaseChecker
10+
from pylint.testutils import MessageTest, UnittestLinter
11+
from pylint.utils import ASTWalker
1812

1913
import pylint_pytest.checkers.fixture
2014

@@ -29,10 +23,9 @@ def get_test_root_path() -> Path:
2923

3024
class BasePytestTester(ABC):
3125
CHECKER_CLASS = BaseChecker
32-
IMPACTED_CHECKER_CLASSES: List[BaseChecker] = []
26+
IMPACTED_CHECKER_CLASSES: List[Type[BaseChecker]] = []
3327
MSG_ID: str
3428
msgs: List[MessageTest] = []
35-
CONFIG: Dict[str, Any] = {}
3629

3730
def __init_subclass__(cls, **kwargs):
3831
super().__init_subclass__(**kwargs)
@@ -78,14 +71,10 @@ def setup_method(self):
7871
self.checker = self.CHECKER_CLASS(self.linter)
7972
self.impacted_checkers = []
8073

81-
for key, value in self.CONFIG.items():
82-
setattr(self.checker.config, key, value)
8374
self.checker.open()
8475

8576
for checker_class in self.IMPACTED_CHECKER_CLASSES:
8677
checker = checker_class(self.linter)
87-
for key, value in self.CONFIG.items():
88-
setattr(checker.config, key, value)
8978
checker.open()
9079
self.impacted_checkers.append(checker)
9180

tests/test_regression.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pylint
21
import pytest
32
from base_tester import BasePytestTester
43
from pylint.checkers.variables import VariablesChecker
@@ -18,9 +17,5 @@ def test_import_twice(self, enable_plugin):
1817
"""catch a coding error when using fixture + if + inline import"""
1918
self.run_linter(enable_plugin)
2019

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

tox.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
[tox]
2-
envlist = py38,py39,py310,py311
2+
envlist =
3+
py38-pylint{2,3}
4+
py39-pylint{2,3}
5+
py310-pylint{2,3}
6+
py311-pylint{2,3}
37
skipsdist = True
48
passenv =
59
FORCE_COLOR
@@ -8,6 +12,8 @@ passenv =
812
deps =
913
pytest
1014
pytest-cov
15+
pylint2: pylint>2,<3
16+
pylint3: pylint>3,<4
1117
commands =
1218
pip install --upgrade --editable .
1319
pytest --cov --cov-append {env:PYTEST_CI_ARGS:} {tty:--color=yes} {posargs:tests}

0 commit comments

Comments
 (0)