Skip to content

Commit 530c8a1

Browse files
authoredMar 18, 2025
Merge pull request #177 from d-ryzhykau/fix-pluggy.Result-import-for-older-pluggy
Fix pluggy.Result import for pluggy<1.3.0
2 parents 251e223 + 1794a02 commit 530c8a1

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed
 

‎src/pytest_check/plugin.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import os
3-
from typing import Generator
3+
from typing import Generator, TYPE_CHECKING
44

55
import pytest
66
from pytest import CallInfo, Config, Item, Parser, TestReport
@@ -11,7 +11,8 @@
1111
ExceptionRepr,
1212
ReprFileLocation,
1313
)
14-
from pluggy import Result
14+
if TYPE_CHECKING: # pragma: no cover
15+
from pluggy import Result
1516

1617
from . import check_log, check_raises, context_manager, pseudo_traceback
1718
from .context_manager import CheckContextManager
@@ -20,8 +21,8 @@
2021
@pytest.hookimpl(hookwrapper=True, trylast=True)
2122
def pytest_runtest_makereport(
2223
item: Item, call: CallInfo[None]
23-
) -> Generator[None, Result[TestReport], None]:
24-
outcome: Result[TestReport] = yield
24+
) -> "Generator[None, Result[TestReport], None]":
25+
outcome: "Result[TestReport]" = yield
2526
report: TestReport = outcome.get_result()
2627

2728
num_failures = check_log._num_failures

‎tox.ini

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,20 @@ commands = ruff check src tests examples
4040
description = Run ruff over src, test, examples
4141

4242
[testenv:mypy]
43-
deps = mypy
43+
deps =
44+
mypy
45+
# pluggy added type checking support in version 1.3.0
46+
pluggy>=1.3,<2
4447
base_python = python3.12
4548
commands =
4649
mypy --strict --pretty src
4750
mypy --pretty tests
4851
description = Run mypy over src, test
4952

5053
[testenv:mypy_earliest]
51-
deps = mypy
54+
deps =
55+
mypy
56+
pluggy>=1.3,<2
5257
base_python = python3.9
5358
commands = mypy --strict --pretty src
5459
description = Run mypy over src for earliest supported python

0 commit comments

Comments
 (0)