Skip to content

Commit a397604

Browse files
bluetechblueyed
authored andcommitted
typing: FSHookProxy/gethookproxy
Taken out of pytest-dev#6556.
1 parent 7609c96 commit a397604

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/_pytest/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def pytest_runtest_logreport(self, report):
449449
def isinitpath(self, path):
450450
return path in self._initialpaths
451451

452-
def gethookproxy(self, fspath):
452+
def gethookproxy(self, fspath: py.path.local):
453453
return super()._gethookproxy(fspath)
454454

455455
def pytest_deselected(self, items):

src/_pytest/nodes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from _pytest.compat import getfslineno
2020
from _pytest.compat import TYPE_CHECKING
2121
from _pytest.config import Config
22+
from _pytest.config import PytestPluginManager
2223
from _pytest.deprecated import NODE_USE_FROM_PARENT
2324
from _pytest.fixtures import FixtureDef
2425
from _pytest.fixtures import FixtureLookupError
@@ -418,12 +419,14 @@ def _check_initialpaths_for_relpath(session, fspath):
418419

419420

420421
class FSHookProxy:
421-
def __init__(self, fspath, pm, remove_mods):
422+
def __init__(
423+
self, fspath: py.path.local, pm: PytestPluginManager, remove_mods
424+
) -> None:
422425
self.fspath = fspath
423426
self.pm = pm
424427
self.remove_mods = remove_mods
425428

426-
def __getattr__(self, name):
429+
def __getattr__(self, name: str):
427430
x = self.pm.subset_hook_caller(name, remove_plugins=self.remove_mods)
428431
self.__dict__[name] = x
429432
return x
@@ -459,7 +462,7 @@ def __init__(
459462
def from_parent(cls, parent, *, fspath):
460463
return cls._create(parent=parent, fspath=fspath)
461464

462-
def _gethookproxy(self, fspath):
465+
def _gethookproxy(self, fspath: py.path.local):
463466
# check if we have the common case of running
464467
# hooks with all conftest.py files
465468
pm = self.config.pluginmanager

src/_pytest/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def setup(self):
582582
func = partial(_call_with_optional_argument, teardown_module, self.obj)
583583
self.addfinalizer(func)
584584

585-
def gethookproxy(self, fspath):
585+
def gethookproxy(self, fspath: py.path.local):
586586
return super()._gethookproxy(fspath)
587587

588588
def _collectfile(self, path, handle_dupes=True):

0 commit comments

Comments
 (0)