34
34
35
35
from .parser import Feature , Scenario , ScenarioTemplate , Step
36
36
37
- P = ParamSpec ("P" )
38
37
T = TypeVar ("T" )
39
38
40
39
logger = logging .getLogger (__name__ )
@@ -201,14 +200,14 @@ def _execute_scenario(feature: Feature, scenario: Scenario, request: FixtureRequ
201
200
202
201
def _get_scenario_decorator (
203
202
feature : Feature , feature_name : str , templated_scenario : ScenarioTemplate , scenario_name : str
204
- ) -> Callable [[Callable [P , T ]], Callable [P , T ]]:
203
+ ) -> Callable [[Callable [... , T ]], Callable [... , T ]]:
205
204
# HACK: Ideally we would use `def decorator(fn)`, but we want to return a custom exception
206
205
# when the decorator is misused.
207
206
# Pytest inspect the signature to determine the required fixtures, and in that case it would look
208
207
# for a fixture called "fn" that doesn't exist (if it exists then it's even worse).
209
208
# It will error with a "fixture 'fn' not found" message instead.
210
209
# We can avoid this hack by using a pytest hook and check for misuse instead.
211
- def decorator (* args : Callable [P , T ]) -> Callable [P , T ]:
210
+ def decorator (* args : Callable [... , T ]) -> Callable [... , T ]:
212
211
if not args :
213
212
raise exceptions .ScenarioIsDecoratorOnly (
214
213
"scenario function can only be used as a decorator. Refer to the documentation."
@@ -241,7 +240,7 @@ def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str
241
240
scenario_wrapper .__doc__ = f"{ feature_name } : { scenario_name } "
242
241
243
242
scenario_wrapper_template_registry [scenario_wrapper ] = templated_scenario
244
- return cast ( Callable [ P , T ], scenario_wrapper )
243
+ return scenario_wrapper
245
244
246
245
return decorator
247
246
@@ -260,7 +259,7 @@ def scenario(
260
259
scenario_name : str ,
261
260
encoding : str = "utf-8" ,
262
261
features_base_dir : str | None = None ,
263
- ) -> Callable [[Callable [P , T ]], Callable [P , T ]]:
262
+ ) -> Callable [[Callable [... , T ]], Callable [... , T ]]:
264
263
"""Scenario decorator.
265
264
266
265
:param str feature_name: Feature file name. Absolute or relative to the configured feature base path.
0 commit comments