Closed mcstoufer closed 3 weeks ago
Verified it isn't there:
more /opt/homebrew/lib/python3.11/site-packages/pytest/init.py
... from _pytest.nodes import Collector ...
Hello @mcstoufer!
Apologies for the very long time it has taken me to respond to your issue. For some reason, I was not informed it was opened π° Edit: Apparently, I was not subscribed to the repo I am maintaining? π€£
I will do some digging and try to make a plan to mitigate your issue tonight.
However, for the sake of completeness, may I ask: Why are you using "such an outdated" pytest version? π
I can see from your log it says pytest-6.2.5
.
I don't know if I'll need it, but do you mind pasting a Scratch that, you did it already π
pip freeze | grep pytest
output?
File "/opt/homebrew/lib/python3.11/site-packages/pylint_pytest/checkers/fixture.py", line 31, in FixtureCollector errors: Set[pytest.CollectReport] = set() ^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'pytest' has no attribute 'CollectReport'. Did you mean: 'Collector'?
Indeed, it seems that this is a pytest-7.0.0rc1 thing:
https://github.com/pytest-dev/pytest/blob/6.2.x/src/_pytest/reports.py#L342-L344 https://github.com/bluetech/pytest/commit/85c372c9d7069dfc3a7deb5c95c60acdc7b4fef6 https://docs.pytest.org/en/8.0.x/changelog.html#id261
I'll do a
if TYPE_CHECKING:
try:
from pytest import CollectReport
except ImportError:
from _pytest.reports import CollectReport
here https://github.com/pylint-dev/pylint-pytest/blob/b6a8f22b7bfa0298f6004ab3051201a8466d0efb/pylint_pytest/checkers/fixture.py#L30 - including testing tomorrow and expanding tox to include pytest v6.
However, do note that the last bugfix of v6.2.5 was 2021-08-29 (https://docs.pytest.org/en/6.2.x/changelog.html#pytest-6-2-5-2021-08-29). I'd suggest you'd updated either way π
Confirmed for me upgrading to pytest 8 (from 6.2.5) fixed the issue.
Confirmed for me upgrading to pytest 8 (from 6.2.5) fixed the issue.
Thank you very much for responding!
Would you kindly test https://github.com/pylint-dev/pylint-pytest/tree/fix/45/missing-pytest.CollectReportin-pytest-6?
I would want to push that fix regardless (I do have a pipeline, but I'd like a human validation regardless π)
Closing, as the fix is verified (update to pytest v8), and no-one is interested to verify the v6 fix
Describe the bug PyLint generation causes stack trace when the pylint-pytest plugin is enabled.
To Reproduce Package versions
$ pylint --version pylint 3.0.2 astroid 3.0.1 Python 3.11.7 (main, Dec 4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)]
$ pytest --version pytest 6.2.5
pylint --output-format=json:pylint.json,parseable tests/test_add_coverage_report_to_pr.py > pylint_report.out
Folder structure
File content
pylint output with the plugin
(Optional) pytest output from fixture collection
Expected behavior The linting report is generated in both JSON and test output.
Additional context This works just fine w/o the pylint-pytest plugin enabled in the .pylintrc file.