Loading stubs/behave-stubs/fixture.pyi +25 −58 Original line number Diff line number Diff line import sys from typing import Any from typing import Iterator from typing import Protocol Loading @@ -13,6 +12,9 @@ C_con = TypeVar("C_con", bound=Context, contravariant=True) R = TypeVar("R") R_co = TypeVar("R_co", covariant=True) P = TypeVar("P", bound=None) P_co = TypeVar("P_co", covariant=True) # unused # There's a lot of @overload-ed functions here as fixtures come in two varieties: # 1) A @contextlib.contextmanager-like generator that yields an arbitrary object once. Loading @@ -20,46 +22,11 @@ R_co = TypeVar("R_co", covariant=True) # # "use_fixture" allows both types of fixture callables to be used in the same way if sys.version_info >= (3, 10) and False: # This depends on complete support of ParamSpec in mypy so is disabled for now. from typing import ParamSpec P = ParamSpec("P") class FixtureCoroutine(Protocol[C_con, P, R_co]): def __call__(self, _: C_con, /, *__a: P.args, **__k: P.kwargs) -> Iterator[R_co]: ... class FixtureFunction(Protocol[C_con, P, R_co]): def __call__(self, _: C_con, /, *__a: P.args, **__k: P.kwargs) -> R_co: ... @overload def use_fixture( fixture_func: FixtureCoroutine[C_con, P, R], context: C_con, *a: P.args, **k: P.kwargs, ) -> R: ... @overload def use_fixture( fixture_func: FixtureFunction[C_con, P, R], context: C_con, *a: P.args, **k: P.kwargs, ) -> R: ... else: # Without ParamSpec no checking is done to ensure the arguments passed to use_fixture # match the fixture's arguments; fixtures must be able to handle arguments not being # supplied (except the context); and fixtures must accept ANY arbitrary keyword # arguments. P = TypeVar("P", bound=None) P_co = TypeVar("P_co", covariant=True) # unused class FixtureCoroutine(Protocol[C_con, P_co, R_co]): def __call__(self, _: C_con, /, *__a: Any, **__k: Any) -> Iterator[R_co]: ... Loading Loading
stubs/behave-stubs/fixture.pyi +25 −58 Original line number Diff line number Diff line import sys from typing import Any from typing import Iterator from typing import Protocol Loading @@ -13,6 +12,9 @@ C_con = TypeVar("C_con", bound=Context, contravariant=True) R = TypeVar("R") R_co = TypeVar("R_co", covariant=True) P = TypeVar("P", bound=None) P_co = TypeVar("P_co", covariant=True) # unused # There's a lot of @overload-ed functions here as fixtures come in two varieties: # 1) A @contextlib.contextmanager-like generator that yields an arbitrary object once. Loading @@ -20,46 +22,11 @@ R_co = TypeVar("R_co", covariant=True) # # "use_fixture" allows both types of fixture callables to be used in the same way if sys.version_info >= (3, 10) and False: # This depends on complete support of ParamSpec in mypy so is disabled for now. from typing import ParamSpec P = ParamSpec("P") class FixtureCoroutine(Protocol[C_con, P, R_co]): def __call__(self, _: C_con, /, *__a: P.args, **__k: P.kwargs) -> Iterator[R_co]: ... class FixtureFunction(Protocol[C_con, P, R_co]): def __call__(self, _: C_con, /, *__a: P.args, **__k: P.kwargs) -> R_co: ... @overload def use_fixture( fixture_func: FixtureCoroutine[C_con, P, R], context: C_con, *a: P.args, **k: P.kwargs, ) -> R: ... @overload def use_fixture( fixture_func: FixtureFunction[C_con, P, R], context: C_con, *a: P.args, **k: P.kwargs, ) -> R: ... else: # Without ParamSpec no checking is done to ensure the arguments passed to use_fixture # match the fixture's arguments; fixtures must be able to handle arguments not being # supplied (except the context); and fixtures must accept ANY arbitrary keyword # arguments. P = TypeVar("P", bound=None) P_co = TypeVar("P_co", covariant=True) # unused class FixtureCoroutine(Protocol[C_con, P_co, R_co]): def __call__(self, _: C_con, /, *__a: Any, **__k: Any) -> Iterator[R_co]: ... Loading