7979
8080
8181# The value of the fixture -- return/yield of the fixture function (type variable).
82- _FixtureValue = TypeVar ("_FixtureValue " )
82+ FixtureValue = TypeVar ("FixtureValue " )
8383# The type of the fixture function (type variable).
84- _FixtureFunction = TypeVar ("_FixtureFunction " , bound = Callable [..., object ])
84+ FixtureFunction = TypeVar ("FixtureFunction " , bound = Callable [..., object ])
8585# The type of a fixture function (type alias generic in fixture value).
8686_FixtureFunc = Union [
87- Callable [..., _FixtureValue ], Callable [..., Generator [_FixtureValue , None , None ]]
87+ Callable [..., FixtureValue ], Callable [..., Generator [FixtureValue , None , None ]]
8888]
8989# The type of FixtureDef.cached_result (type alias generic in fixture value).
9090_FixtureCachedResult = Union [
9191 Tuple [
9292 # The result.
93- _FixtureValue ,
93+ FixtureValue ,
9494 # Cache key.
9595 object ,
9696 None ,
106106
107107
108108@attr .s (frozen = True )
109- class PseudoFixtureDef (Generic [_FixtureValue ]):
110- cached_result = attr .ib (type = "_FixtureCachedResult[_FixtureValue ]" )
109+ class PseudoFixtureDef (Generic [FixtureValue ]):
110+ cached_result = attr .ib (type = "_FixtureCachedResult[FixtureValue ]" )
111111 scope = attr .ib (type = "_Scope" )
112112
113113
@@ -928,11 +928,11 @@ def fail_fixturefunc(fixturefunc, msg: str) -> "NoReturn":
928928
929929
930930def call_fixture_func (
931- fixturefunc : "_FixtureFunc[_FixtureValue ]" , request : FixtureRequest , kwargs
932- ) -> _FixtureValue :
931+ fixturefunc : "_FixtureFunc[FixtureValue ]" , request : FixtureRequest , kwargs
932+ ) -> FixtureValue :
933933 if is_generator (fixturefunc ):
934934 fixturefunc = cast (
935- Callable [..., Generator [_FixtureValue , None , None ]], fixturefunc
935+ Callable [..., Generator [FixtureValue , None , None ]], fixturefunc
936936 )
937937 generator = fixturefunc (** kwargs )
938938 try :
@@ -942,7 +942,7 @@ def call_fixture_func(
942942 finalizer = functools .partial (_teardown_yield_fixture , fixturefunc , generator )
943943 request .addfinalizer (finalizer )
944944 else :
945- fixturefunc = cast (Callable [..., _FixtureValue ], fixturefunc )
945+ fixturefunc = cast (Callable [..., FixtureValue ], fixturefunc )
946946 fixture_result = fixturefunc (** kwargs )
947947 return fixture_result
948948
@@ -985,15 +985,15 @@ def _eval_scope_callable(
985985
986986
987987@final
988- class FixtureDef (Generic [_FixtureValue ]):
988+ class FixtureDef (Generic [FixtureValue ]):
989989 """A container for a factory definition."""
990990
991991 def __init__ (
992992 self ,
993993 fixturemanager : "FixtureManager" ,
994994 baseid : Optional [str ],
995995 argname : str ,
996- func : "_FixtureFunc[_FixtureValue ]" ,
996+ func : "_FixtureFunc[FixtureValue ]" ,
997997 scope : "Union[_Scope, Callable[[str, Config], _Scope]]" ,
998998 params : Optional [Sequence [object ]],
999999 unittest : bool = False ,
@@ -1026,7 +1026,7 @@ def __init__(
10261026 )
10271027 self .unittest = unittest
10281028 self .ids = ids
1029- self .cached_result : Optional [_FixtureCachedResult [_FixtureValue ]] = None
1029+ self .cached_result : Optional [_FixtureCachedResult [FixtureValue ]] = None
10301030 self ._finalizers : List [Callable [[], object ]] = []
10311031
10321032 def addfinalizer (self , finalizer : Callable [[], object ]) -> None :
@@ -1055,7 +1055,7 @@ def finish(self, request: SubRequest) -> None:
10551055 self .cached_result = None
10561056 self ._finalizers = []
10571057
1058- def execute (self , request : SubRequest ) -> _FixtureValue :
1058+ def execute (self , request : SubRequest ) -> FixtureValue :
10591059 # Get required arguments and register our own finish()
10601060 # with their finalization.
10611061 for argname in self .argnames :
@@ -1096,8 +1096,8 @@ def __repr__(self) -> str:
10961096
10971097
10981098def resolve_fixture_function (
1099- fixturedef : FixtureDef [_FixtureValue ], request : FixtureRequest
1100- ) -> "_FixtureFunc[_FixtureValue ]" :
1099+ fixturedef : FixtureDef [FixtureValue ], request : FixtureRequest
1100+ ) -> "_FixtureFunc[FixtureValue ]" :
11011101 """Get the actual callable that can be called to obtain the fixture
11021102 value, dealing with unittest-specific instances and bound methods."""
11031103 fixturefunc = fixturedef .func
@@ -1123,8 +1123,8 @@ def resolve_fixture_function(
11231123
11241124
11251125def pytest_fixture_setup (
1126- fixturedef : FixtureDef [_FixtureValue ], request : SubRequest
1127- ) -> _FixtureValue :
1126+ fixturedef : FixtureDef [FixtureValue ], request : SubRequest
1127+ ) -> FixtureValue :
11281128 """Execution of fixture setup."""
11291129 kwargs = {}
11301130 for argname in fixturedef .argnames :
@@ -1174,9 +1174,9 @@ def _params_converter(
11741174
11751175
11761176def wrap_function_to_error_out_if_called_directly (
1177- function : _FixtureFunction ,
1177+ function : FixtureFunction ,
11781178 fixture_marker : "FixtureFunctionMarker" ,
1179- ) -> _FixtureFunction :
1179+ ) -> FixtureFunction :
11801180 """Wrap the given fixture function so we can raise an error about it being called directly,
11811181 instead of used as an argument in a test function."""
11821182 message = (
@@ -1194,7 +1194,7 @@ def result(*args, **kwargs):
11941194 # further than this point and lose useful wrappings like @mock.patch (#3774).
11951195 result .__pytest_wrapped__ = _PytestWrapper (function ) # type: ignore[attr-defined]
11961196
1197- return cast (_FixtureFunction , result )
1197+ return cast (FixtureFunction , result )
11981198
11991199
12001200@final
@@ -1213,7 +1213,7 @@ class FixtureFunctionMarker:
12131213 )
12141214 name = attr .ib (type = Optional [str ], default = None )
12151215
1216- def __call__ (self , function : _FixtureFunction ) -> _FixtureFunction :
1216+ def __call__ (self , function : FixtureFunction ) -> FixtureFunction :
12171217 if inspect .isclass (function ):
12181218 raise ValueError ("class fixtures not supported (maybe in the future)" )
12191219
@@ -1241,7 +1241,7 @@ def __call__(self, function: _FixtureFunction) -> _FixtureFunction:
12411241
12421242@overload
12431243def fixture (
1244- fixture_function : _FixtureFunction ,
1244+ fixture_function : FixtureFunction ,
12451245 * ,
12461246 scope : "Union[_Scope, Callable[[str, Config], _Scope]]" = ...,
12471247 params : Optional [Iterable [object ]] = ...,
@@ -1253,7 +1253,7 @@ def fixture(
12531253 ]
12541254 ] = ...,
12551255 name : Optional [str ] = ...,
1256- ) -> _FixtureFunction :
1256+ ) -> FixtureFunction :
12571257 ...
12581258
12591259
@@ -1276,7 +1276,7 @@ def fixture(
12761276
12771277
12781278def fixture (
1279- fixture_function : Optional [_FixtureFunction ] = None ,
1279+ fixture_function : Optional [FixtureFunction ] = None ,
12801280 * ,
12811281 scope : "Union[_Scope, Callable[[str, Config], _Scope]]" = "function" ,
12821282 params : Optional [Iterable [object ]] = None ,
@@ -1288,7 +1288,7 @@ def fixture(
12881288 ]
12891289 ] = None ,
12901290 name : Optional [str ] = None ,
1291- ) -> Union [FixtureFunctionMarker , _FixtureFunction ]:
1291+ ) -> Union [FixtureFunctionMarker , FixtureFunction ]:
12921292 """Decorator to mark a fixture factory function.
12931293
12941294 This decorator can be used, with or without parameters, to define a
0 commit comments