Skip to content

Commit a39b4e2

Browse files
committed
typing: Testdir.plugins
1 parent 0b3b55d commit a39b4e2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/_pytest/config/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
from typing import Type
4949

5050

51+
_PluggyPlugin = object
52+
"""A type to represent plugin objects.
53+
Plugins can be any namespace, so we can't narrow it down much, but we use an
54+
alias to make the intent clear.
55+
Ideally this type would be provided by pluggy itself."""
56+
57+
5158
hookimpl = HookimplMarker("pytest")
5259
hookspec = HookspecMarker("pytest")
5360

src/_pytest/pytester.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from _pytest.capture import MultiCapture
3030
from _pytest.capture import SysCapture
3131
from _pytest.compat import TYPE_CHECKING
32+
from _pytest.config import _PluggyPlugin
3233
from _pytest.fixtures import FixtureRequest
3334
from _pytest.main import ExitCode
3435
from _pytest.main import Session
@@ -546,7 +547,7 @@ def __init__(self, request: FixtureRequest, tmpdir_factory: TempdirFactory) -> N
546547
name = request.function.__name__
547548
self.tmpdir = tmpdir_factory.mktemp(name, numbered=True)
548549
self.test_tmproot = tmpdir_factory.mktemp("tmp-" + name, numbered=True)
549-
self.plugins = [] # type: ignore[var-annotated] # noqa: F821
550+
self.plugins = [] # type: Sequence[Union[str, _PluggyPlugin]]
550551
self._cwd_snapshot = CwdSnapshot()
551552
self._sys_path_snapshot = SysPathsSnapshot()
552553
self._sys_modules_snapshot = self.__take_sys_modules_snapshot()

0 commit comments

Comments
 (0)