Skip to content

Commit

Permalink
Use FixtureRequest instead of SubRequest
Browse files Browse the repository at this point in the history
`SubRequest` is a subclass of `FixtureRequest`, but is currently private
so pytest-asyncio uses `Any` instead. However, `FixtureRequest` typing
is sufficient for our needs, so can use that instead.
  • Loading branch information
bluetech authored and seifertm committed Mar 19, 2024
1 parent c3429fa commit cdd2c49
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pytest_asyncio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@

# https://github.com/pytest-dev/pytest/pull/9510
FixtureDef = Any
SubRequest = Any


class PytestAsyncioError(Exception):
Expand Down Expand Up @@ -282,7 +281,7 @@ def _add_kwargs(
kwargs: Dict[str, Any],
event_loop_fixture_id: str,
event_loop: asyncio.AbstractEventLoop,
request: SubRequest,
request: FixtureRequest,
) -> Dict[str, Any]:
sig = inspect.signature(func)
ret = kwargs.copy()
Expand Down Expand Up @@ -316,7 +315,7 @@ def _wrap_asyncgen_fixture(fixturedef: FixtureDef, event_loop_fixture_id: str) -
fixture = fixturedef.func

@functools.wraps(fixture)
def _asyncgen_fixture_wrapper(request: SubRequest, **kwargs: Any):
def _asyncgen_fixture_wrapper(request: FixtureRequest, **kwargs: Any):
func = _perhaps_rebind_fixture_func(
fixture, request.instance, fixturedef.unittest
)
Expand Down Expand Up @@ -355,7 +354,7 @@ def _wrap_async_fixture(fixturedef: FixtureDef, event_loop_fixture_id: str) -> N
fixture = fixturedef.func

@functools.wraps(fixture)
def _async_fixture_wrapper(request: SubRequest, **kwargs: Any):
def _async_fixture_wrapper(request: FixtureRequest, **kwargs: Any):
func = _perhaps_rebind_fixture_func(
fixture, request.instance, fixturedef.unittest
)
Expand Down

0 comments on commit cdd2c49

Please sign in to comment.