Skip to content

Commit

Permalink
Add FixtureDefDict type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Dec 7, 2024
1 parent 9f78c6c commit 348068c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
# The parameters that a fixture function receives.
FixtureParams = ParamSpec("FixtureParams")

# A dict of fixture name -> its FixtureDef.
FixtureDefDict: TypeAlias = dict[str, "FixtureDef[Any]"]

# The type of fixture function (type alias generic in fixture params and value).
_FixtureFunc: TypeAlias = Union[
Callable[FixtureParams, FixtureValue],
Expand Down Expand Up @@ -370,7 +373,7 @@ def __init__(
pyfuncitem: Function,
fixturename: str | None,
arg2fixturedefs: dict[str, Sequence[FixtureDef[Any]]],
fixture_defs: dict[str, FixtureDef[Any]],
fixture_defs: FixtureDefDict,
*,
_ispytest: bool = False,
) -> None:
Expand Down
5 changes: 3 additions & 2 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from _pytest.config.argparsing import Parser
from _pytest.deprecated import check_ispytest
from _pytest.fixtures import FixtureDef
from _pytest.fixtures import FixtureDefDict
from _pytest.fixtures import FixtureRequest
from _pytest.fixtures import FuncFixtureInfo
from _pytest.fixtures import get_scope_node
Expand Down Expand Up @@ -1085,7 +1086,7 @@ def get_direct_param_fixture_func(request: FixtureRequest) -> Any:


# Used for storing pseudo fixturedefs for direct parametrization.
name2pseudofixturedef_key = StashKey[dict[str, FixtureDef[Any]]]()
name2pseudofixturedef_key = StashKey[FixtureDefDict]()


@final
Expand Down Expand Up @@ -1271,7 +1272,7 @@ def parametrize(
if node is None:
name2pseudofixturedef = None
else:
default: dict[str, FixtureDef[Any]] = {}
default: FixtureDefDict = {}
name2pseudofixturedef = node.stash.setdefault(
name2pseudofixturedef_key, default
)
Expand Down

0 comments on commit 348068c

Please sign in to comment.