hookspec: type annotate parent argument to pytest_collect_file
This commit is contained in:
parent
4b8e1a1771
commit
57aca11d4a
|
@ -32,6 +32,7 @@ from _pytest.compat import TYPE_CHECKING
|
||||||
from _pytest.config import Config
|
from _pytest.config import Config
|
||||||
from _pytest.config.argparsing import Parser
|
from _pytest.config.argparsing import Parser
|
||||||
from _pytest.fixtures import FixtureRequest
|
from _pytest.fixtures import FixtureRequest
|
||||||
|
from _pytest.nodes import Collector
|
||||||
from _pytest.outcomes import OutcomeException
|
from _pytest.outcomes import OutcomeException
|
||||||
from _pytest.pathlib import import_path
|
from _pytest.pathlib import import_path
|
||||||
from _pytest.python_api import approx
|
from _pytest.python_api import approx
|
||||||
|
@ -118,7 +119,7 @@ def pytest_unconfigure() -> None:
|
||||||
|
|
||||||
|
|
||||||
def pytest_collect_file(
|
def pytest_collect_file(
|
||||||
path: py.path.local, parent
|
path: py.path.local, parent: Collector,
|
||||||
) -> Optional[Union["DoctestModule", "DoctestTextfile"]]:
|
) -> Optional[Union["DoctestModule", "DoctestTextfile"]]:
|
||||||
config = parent.config
|
config = parent.config
|
||||||
if path.ext == ".py":
|
if path.ext == ".py":
|
||||||
|
|
|
@ -274,10 +274,12 @@ def pytest_ignore_collect(path: py.path.local, config: "Config") -> Optional[boo
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def pytest_collect_file(path: py.path.local, parent) -> "Optional[Collector]":
|
def pytest_collect_file(
|
||||||
"""Return collection Node or None for the given path.
|
path: py.path.local, parent: "Collector"
|
||||||
|
) -> "Optional[Collector]":
|
||||||
|
"""Create a Collector for the given path, or None if not relevant.
|
||||||
|
|
||||||
Any new node needs to have the specified ``parent`` as a parent.
|
The new node needs to have the specified ``parent`` as a parent.
|
||||||
|
|
||||||
:param py.path.local path: The path to collect.
|
:param py.path.local path: The path to collect.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -184,7 +184,9 @@ def pytest_pyfunc_call(pyfuncitem: "Function") -> Optional[object]:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def pytest_collect_file(path: py.path.local, parent) -> Optional["Module"]:
|
def pytest_collect_file(
|
||||||
|
path: py.path.local, parent: nodes.Collector
|
||||||
|
) -> Optional["Module"]:
|
||||||
ext = path.ext
|
ext = path.ext
|
||||||
if ext == ".py":
|
if ext == ".py":
|
||||||
if not parent.session.isinitpath(path):
|
if not parent.session.isinitpath(path):
|
||||||
|
|
Loading…
Reference in New Issue