Skip to content

Commit

Permalink
Merge branch 'main' into tomli
Browse files Browse the repository at this point in the history
  • Loading branch information
carsongee authored Oct 6, 2023
2 parents ca95924 + 6a09517 commit 90e8b46
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 36 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ If you want to help development, there is
Releases
========

0.20.0
~~~~~~
- Corrected issues introduced by deprecations in pylint
- Added support for Python 3.12 and dropped support for Python 3.7
- Last version that will support pytest < 7 and pylint < 2.6

0.19.0
~~~~~~

Expand Down
29 changes: 11 additions & 18 deletions pytest_pylint/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,7 @@ def pytest_configure(self, config):
if config.option.pylint_rcfile:
pylintrc_file = config.option.pylint_rcfile
else:
# handling files apart from pylintrc was only introduced in pylint
# 2.5, if we can't use find_default_config_files(), fall back on PYLINTRC
# once we drop support below 2.5 we can get rid of this
try:
pylintrc_file = next(pylint_config.find_default_config_files(), None)
except AttributeError:
# pylint: disable=no-member
pylintrc_file = pylint_config.PYLINTRC
pylintrc_file = next(pylint_config.find_default_config_files(), None)

if pylintrc_file and not exists(pylintrc_file):
# The directory of pytest.ini got a chance
Expand Down Expand Up @@ -232,11 +225,11 @@ def pytest_collect_file(self, path, parent):
if path.ext != ".py":
return None

rel_path = get_rel_path(path.strpath, parent.session.fspath.strpath)
rel_path = get_rel_path(path.strpath, str(parent.session.path))
if should_include_file(
rel_path, self.pylint_ignore, self.pylint_ignore_patterns
):
item = PylintFile.from_parent(parent, fspath=path, plugin=self)
item = PylintFile.from_parent(parent, path=Path(path), plugin=self)
else:
return None

Expand Down Expand Up @@ -311,15 +304,15 @@ class PylintFile(pytest.File):
mtime = None # : float

@classmethod
def from_parent(cls, parent, *, fspath, plugin):
def from_parent(cls, parent, *, path, plugin, **kw):
# pylint: disable=arguments-differ
# We add the ``plugin`` kwarg to get plugin level information so the
# signature differs
# pylint: disable=arguments-differ
_self = getattr(super(), "from_parent", cls)(parent, fspath=fspath)
_self = getattr(super(), "from_parent", cls)(parent, path=path, **kw)
_self.plugin = plugin

_self.rel_path = get_rel_path(fspath.strpath, parent.session.fspath.strpath)
_self.mtime = fspath.mtime()
_self.rel_path = get_rel_path(str(path), str(parent.session.path))
_self.mtime = path.stat().st_mtime
prev_mtime = _self.plugin.mtimes.get(_self.rel_path, 0)
_self.should_skip = prev_mtime == _self.mtime

Expand All @@ -336,8 +329,8 @@ class PyLintItem(pytest.Item):
parent = None # : PylintFile
plugin = None # : PylintPlugin

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
self.add_marker(MARKER)
self.plugin = self.parent.plugin

Expand Down Expand Up @@ -399,4 +392,4 @@ def repr_failure(self, excinfo, style=None):
def reportinfo(self):
"""Generate our test report"""
# pylint: disable=no-member
return self.fspath, None, f"[pylint] {self.parent.rel_path}"
return self.path, None, f"[pylint] {self.parent.rel_path}"
12 changes: 6 additions & 6 deletions pytest_pylint/tests/test_pytest_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Unit testing module for pytest-pylint plugin
"""
import os
import pathlib
import re
from textwrap import dedent
from unittest import mock
Expand Down Expand Up @@ -312,8 +312,8 @@ def test_output_file(testdir):
"""Verify pylint report output"""
testdir.makepyfile("import sys")
testdir.runpytest("--pylint", "--pylint-output-file=pylint.report")
output_file = os.path.join(testdir.tmpdir.strpath, "pylint.report")
assert os.path.isfile(output_file)
output_file = pathlib.Path(testdir.tmpdir.strpath) / "pylint.report"
assert output_file.is_file()

with open(output_file, "r", encoding="utf-8") as _file:
report = _file.read()
Expand All @@ -339,10 +339,10 @@ def test_output_file(testdir):
def test_output_file_makes_dirs(testdir):
"""Verify output works with folders properly."""
testdir.makepyfile("import sys")
output_path = os.path.join("reports", "pylint.report")
output_path = pathlib.Path("reports", "pylint.report")
testdir.runpytest("--pylint", f"--pylint-output-file={output_path}")
output_file = os.path.join(testdir.tmpdir.strpath, output_path)
assert os.path.isfile(output_file)
output_file = pathlib.Path(testdir.tmpdir.strpath) / output_path
assert output_file.is_file()
# Run again to make sure we don't crash trying to make a dir that exists
testdir.runpytest("--pylint", f"--pylint-output-file={output_path}")

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
description="pytest plugin to check source code with pylint",
long_description=LONG_DESCRIPTION,
license="MIT",
version="0.19.0",
version="0.20.0",
author="Carson Gee",
author_email="x@carsongee.com",
url="https://github.com/carsongee/pytest-pylint",
packages=["pytest_pylint"],
entry_points={"pytest11": ["pylint = pytest_pylint.plugin"]},
python_requires=">=3.7",
install_requires=[
"pytest>=5.4,<8.0",
"pylint>=2.3.0",
"pytest>=7.0",
"pylint>=2.15.0",
"tomli>=1.1.0; python_version < '3.11'",
],
setup_requires=["pytest-runner"],
Expand Down
14 changes: 5 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
[tox]
envlist =
py3{8, 9}-pylint{26, 30}-pytest{54}
py3{8, 9, 10}-pylint{213, 214, 30}-pytest{71}
py3{8, 9, 10, 11}-pylint{215, latest, main}-pytest{71, latest}
py3{12}-pylint{latest, main}-pytest{71, latest}
py3{8, 9, 10}-pylint{215, 30}-pytest{7}
py3{8, 9, 10, 11}-pylint{215, latest, main}-pytest{7, latest, main}
py3{12}-pylint{latest, main}-pytest{7, latest, main}
coverage
qa
skip_missing_interpreters = true

[testenv]
usedevelop = true
deps =
pylint215: pylint~=2.15.10
pylint30: pylint~=3.0
pylint26: pylint~=2.6.0
pylint213: pylint~=2.13.9
pylint214: pylint~=2.14.5
pylint215: pylint~=2.15.0
pylintlatest: pylint
pylintmain: git+https://github.com/PyCQA/pylint.git@main#egg=pylint
pylintmain: git+https://github.com/PyCQA/astroid.git@main#egg=astroid
pytest7: pytest~=7.1.2
pytest7: pytest~=7.0.0
pytestlatest: pytest
pytestmain: git+https://github.com/pytest-dev/pytest.git@main#egg=pytest
coverage
Expand Down

0 comments on commit 90e8b46

Please sign in to comment.