@@ -131,7 +131,7 @@ def pytest_sessionstart(session: Session) -> None:
131
131
132
132
def get_scope_package (
133
133
node : nodes .Item ,
134
- fixturedef : FixtureDef [Any , object ],
134
+ fixturedef : FixtureDef [object ],
135
135
) -> nodes .Node | None :
136
136
from _pytest .python import Package
137
137
@@ -328,7 +328,7 @@ class FuncFixtureInfo:
328
328
# matching the name which are applicable to this function.
329
329
# There may be multiple overriding fixtures with the same name. The
330
330
# sequence is ordered from furthest to closes to the function.
331
- name2fixturedefs : dict [str , Sequence [FixtureDef [Any , Any ]]]
331
+ name2fixturedefs : dict [str , Sequence [FixtureDef [Any ]]]
332
332
333
333
def prune_dependency_tree (self ) -> None :
334
334
"""Recompute names_closure from initialnames and name2fixturedefs.
@@ -369,8 +369,8 @@ def __init__(
369
369
self ,
370
370
pyfuncitem : Function ,
371
371
fixturename : str | None ,
372
- arg2fixturedefs : dict [str , Sequence [FixtureDef [Any , Any ]]],
373
- fixture_defs : dict [str , FixtureDef [Any , Any ]],
372
+ arg2fixturedefs : dict [str , Sequence [FixtureDef [Any ]]],
373
+ fixture_defs : dict [str , FixtureDef [Any ]],
374
374
* ,
375
375
_ispytest : bool = False ,
376
376
) -> None :
@@ -413,7 +413,7 @@ def scope(self) -> _ScopeName:
413
413
@abc .abstractmethod
414
414
def _check_scope (
415
415
self ,
416
- requested_fixturedef : FixtureDef [Any , object ] | PseudoFixtureDef [object ],
416
+ requested_fixturedef : FixtureDef [object ] | PseudoFixtureDef [object ],
417
417
requested_scope : Scope ,
418
418
) -> None :
419
419
raise NotImplementedError ()
@@ -554,7 +554,7 @@ def _iter_chain(self) -> Iterator[SubRequest]:
554
554
555
555
def _get_active_fixturedef (
556
556
self , argname : str
557
- ) -> FixtureDef [Any , object ] | PseudoFixtureDef [object ]:
557
+ ) -> FixtureDef [object ] | PseudoFixtureDef [object ]:
558
558
if argname == "request" :
559
559
cached_result = (self , [0 ], None )
560
560
return PseudoFixtureDef (cached_result , Scope .Function )
@@ -626,9 +626,7 @@ def _get_active_fixturedef(
626
626
self ._fixture_defs [argname ] = fixturedef
627
627
return fixturedef
628
628
629
- def _check_fixturedef_without_param (
630
- self , fixturedef : FixtureDef [Any , object ]
631
- ) -> None :
629
+ def _check_fixturedef_without_param (self , fixturedef : FixtureDef [object ]) -> None :
632
630
"""Check that this request is allowed to execute this fixturedef without
633
631
a param."""
634
632
funcitem = self ._pyfuncitem
@@ -661,7 +659,7 @@ def _check_fixturedef_without_param(
661
659
)
662
660
fail (msg , pytrace = False )
663
661
664
- def _get_fixturestack (self ) -> list [FixtureDef [Any , Any ]]:
662
+ def _get_fixturestack (self ) -> list [FixtureDef [Any ]]:
665
663
values = [request ._fixturedef for request in self ._iter_chain ()]
666
664
values .reverse ()
667
665
return values
@@ -686,7 +684,7 @@ def _scope(self) -> Scope:
686
684
687
685
def _check_scope (
688
686
self ,
689
- requested_fixturedef : FixtureDef [Any , object ] | PseudoFixtureDef [object ],
687
+ requested_fixturedef : FixtureDef [object ] | PseudoFixtureDef [object ],
690
688
requested_scope : Scope ,
691
689
) -> None :
692
690
# TopRequest always has function scope so always valid.
@@ -720,7 +718,7 @@ def __init__(
720
718
scope : Scope ,
721
719
param : Any ,
722
720
param_index : int ,
723
- fixturedef : FixtureDef [Any , object ],
721
+ fixturedef : FixtureDef [object ],
724
722
* ,
725
723
_ispytest : bool = False ,
726
724
) -> None :
@@ -733,7 +731,7 @@ def __init__(
733
731
)
734
732
self ._parent_request : Final [FixtureRequest ] = request
735
733
self ._scope_field : Final = scope
736
- self ._fixturedef : Final [FixtureDef [Any , object ]] = fixturedef
734
+ self ._fixturedef : Final [FixtureDef [object ]] = fixturedef
737
735
if param is not NOTSET :
738
736
self .param = param
739
737
self .param_index : Final = param_index
@@ -763,7 +761,7 @@ def node(self):
763
761
764
762
def _check_scope (
765
763
self ,
766
- requested_fixturedef : FixtureDef [Any , object ] | PseudoFixtureDef [object ],
764
+ requested_fixturedef : FixtureDef [object ] | PseudoFixtureDef [object ],
767
765
requested_scope : Scope ,
768
766
) -> None :
769
767
if isinstance (requested_fixturedef , PseudoFixtureDef ):
@@ -784,7 +782,7 @@ def _check_scope(
784
782
pytrace = False ,
785
783
)
786
784
787
- def _format_fixturedef_line (self , fixturedef : FixtureDef [Any , object ]) -> str :
785
+ def _format_fixturedef_line (self , fixturedef : FixtureDef [object ]) -> str :
788
786
factory = fixturedef .func
789
787
path , lineno = getfslineno (factory )
790
788
if isinstance (path , Path ):
@@ -959,7 +957,7 @@ def _eval_scope_callable(
959
957
960
958
961
959
@final
962
- class FixtureDef (Generic [FixtureParams , FixtureValue ]):
960
+ class FixtureDef (Generic [FixtureValue ]):
963
961
"""A container for a fixture definition.
964
962
965
963
This is a generic class parametrized on the parameters that a fixture function receives and its return value.
@@ -973,7 +971,7 @@ def __init__(
973
971
config : Config ,
974
972
baseid : str | None ,
975
973
argname : str ,
976
- func : _FixtureFunc [FixtureParams , FixtureValue ],
974
+ func : _FixtureFunc [Any , FixtureValue ],
977
975
scope : Scope | _ScopeName | Callable [[str , Config ], _ScopeName ] | None ,
978
976
params : Sequence [object ] | None ,
979
977
ids : tuple [object | None , ...] | Callable [[Any ], object | None ] | None = None ,
@@ -1128,8 +1126,8 @@ def __repr__(self) -> str:
1128
1126
1129
1127
1130
1128
def resolve_fixture_function (
1131
- fixturedef : FixtureDef [FixtureParams , FixtureValue ], request : FixtureRequest
1132
- ) -> _FixtureFunc [FixtureParams , FixtureValue ]:
1129
+ fixturedef : FixtureDef [FixtureValue ], request : FixtureRequest
1130
+ ) -> _FixtureFunc [Any , FixtureValue ]:
1133
1131
"""Get the actual callable that can be called to obtain the fixture
1134
1132
value."""
1135
1133
fixturefunc = fixturedef .func
@@ -1152,7 +1150,7 @@ def resolve_fixture_function(
1152
1150
1153
1151
1154
1152
def pytest_fixture_setup (
1155
- fixturedef : FixtureDef [FixtureParams , FixtureValue ], request : SubRequest
1153
+ fixturedef : FixtureDef [FixtureValue ], request : SubRequest
1156
1154
) -> FixtureValue :
1157
1155
"""Execution of fixture setup."""
1158
1156
kwargs = {}
@@ -1525,7 +1523,7 @@ def __init__(self, session: Session) -> None:
1525
1523
# suite/plugins defined with this name. Populated by parsefactories().
1526
1524
# TODO: The order of the FixtureDefs list of each arg is significant,
1527
1525
# explain.
1528
- self ._arg2fixturedefs : Final [dict [str , list [FixtureDef [Any , Any ]]]] = {}
1526
+ self ._arg2fixturedefs : Final [dict [str , list [FixtureDef [Any ]]]] = {}
1529
1527
self ._holderobjseen : Final [set [object ]] = set ()
1530
1528
# A mapping from a nodeid to a list of autouse fixtures it defines.
1531
1529
self ._nodeid_autousenames : Final [dict [str , list [str ]]] = {
@@ -1616,7 +1614,7 @@ def getfixtureclosure(
1616
1614
parentnode : nodes .Node ,
1617
1615
initialnames : tuple [str , ...],
1618
1616
ignore_args : AbstractSet [str ],
1619
- ) -> tuple [list [str ], dict [str , Sequence [FixtureDef [Any , Any ]]]]:
1617
+ ) -> tuple [list [str ], dict [str , Sequence [FixtureDef [Any ]]]]:
1620
1618
# Collect the closure of all fixtures, starting with the given
1621
1619
# fixturenames as the initial set. As we have to visit all
1622
1620
# factory definitions anyway, we also return an arg2fixturedefs
@@ -1626,7 +1624,7 @@ def getfixtureclosure(
1626
1624
1627
1625
fixturenames_closure = list (initialnames )
1628
1626
1629
- arg2fixturedefs : dict [str , Sequence [FixtureDef [Any , Any ]]] = {}
1627
+ arg2fixturedefs : dict [str , Sequence [FixtureDef [Any ]]] = {}
1630
1628
lastlen = - 1
1631
1629
while lastlen != len (fixturenames_closure ):
1632
1630
lastlen = len (fixturenames_closure )
@@ -1841,7 +1839,7 @@ def parsefactories(
1841
1839
1842
1840
def getfixturedefs (
1843
1841
self , argname : str , node : nodes .Node
1844
- ) -> Sequence [FixtureDef [Any , Any ]] | None :
1842
+ ) -> Sequence [FixtureDef [Any ]] | None :
1845
1843
"""Get FixtureDefs for a fixture name which are applicable
1846
1844
to a given node.
1847
1845
@@ -1860,8 +1858,8 @@ def getfixturedefs(
1860
1858
return tuple (self ._matchfactories (fixturedefs , node ))
1861
1859
1862
1860
def _matchfactories (
1863
- self , fixturedefs : Iterable [FixtureDef [Any , Any ]], node : nodes .Node
1864
- ) -> Iterator [FixtureDef [Any , Any ]]:
1861
+ self , fixturedefs : Iterable [FixtureDef [Any ]], node : nodes .Node
1862
+ ) -> Iterator [FixtureDef [Any ]]:
1865
1863
parentnodeids = {n .nodeid for n in node .iter_parents ()}
1866
1864
for fixturedef in fixturedefs :
1867
1865
if fixturedef .baseid in parentnodeids :
@@ -1898,7 +1896,7 @@ def get_best_relpath(func) -> str:
1898
1896
loc = getlocation (func , invocation_dir )
1899
1897
return bestrelpath (invocation_dir , Path (loc ))
1900
1898
1901
- def write_fixture (fixture_def : FixtureDef [Any , object ]) -> None :
1899
+ def write_fixture (fixture_def : FixtureDef [object ]) -> None :
1902
1900
argname = fixture_def .argname
1903
1901
if verbose <= 0 and argname .startswith ("_" ):
1904
1902
return
0 commit comments