Skip to content

Commit f002e4a

Browse files
committed
Add FixtureDefDict type alias
1 parent 9749d28 commit f002e4a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/_pytest/fixtures.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
# The parameters that a fixture function receives.
9696
FixtureParams = ParamSpec("FixtureParams")
9797

98+
# A dict of fixture name -> its FixtureDef.
99+
FixtureDefDict: TypeAlias = dict[str, "FixtureDef[FixtureValue]"]
100+
98101
# The type of fixture function (type alias generic in fixture params and value).
99102
_FixtureFunc: TypeAlias = Union[
100103
Callable[FixtureParams, FixtureValue],
@@ -370,7 +373,7 @@ def __init__(
370373
pyfuncitem: Function,
371374
fixturename: str | None,
372375
arg2fixturedefs: dict[str, Sequence[FixtureDef[Any]]],
373-
fixture_defs: dict[str, FixtureDef[Any]],
376+
fixture_defs: FixtureDefDict[Any],
374377
*,
375378
_ispytest: bool = False,
376379
) -> None:

src/_pytest/python.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from _pytest.config.argparsing import Parser
5252
from _pytest.deprecated import check_ispytest
5353
from _pytest.fixtures import FixtureDef
54+
from _pytest.fixtures import FixtureDefDict
5455
from _pytest.fixtures import FixtureRequest
5556
from _pytest.fixtures import FuncFixtureInfo
5657
from _pytest.fixtures import get_scope_node
@@ -1085,7 +1086,7 @@ def get_direct_param_fixture_func(request: FixtureRequest) -> Any:
10851086

10861087

10871088
# Used for storing pseudo fixturedefs for direct parametrization.
1088-
name2pseudofixturedef_key = StashKey[dict[str, FixtureDef[Any]]]()
1089+
name2pseudofixturedef_key = StashKey[FixtureDefDict[Any]]()
10891090

10901091

10911092
@final
@@ -1271,7 +1272,7 @@ def parametrize(
12711272
if node is None:
12721273
name2pseudofixturedef = None
12731274
else:
1274-
default: dict[str, FixtureDef[Any]] = {}
1275+
default: FixtureDefDict[Any] = {}
12751276
name2pseudofixturedef = node.stash.setdefault(
12761277
name2pseudofixturedef_key, default
12771278
)

0 commit comments

Comments
 (0)