From c13f35962b633e7e144889ae9546c3defaffa436 Mon Sep 17 00:00:00 2001 From: starod00m Date: Fri, 20 Sep 2024 09:39:00 +0500 Subject: [PATCH] Add typehints for step func returning types --- allure-python-commons/src/_allure.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index 05e01dbd..31b2e38e 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -1,5 +1,5 @@ from functools import wraps -from typing import Any, Callable, TypeVar +from typing import Any, Callable, TypeVar, Union, overload from allure_commons._core import plugin_manager from allure_commons.types import LabelType, LinkType, ParameterMode @@ -161,7 +161,15 @@ def manual(): return Dynamic.label(LabelType.MANUAL, True) -def step(title): +@overload +def step(title: str) -> "StepContext": ... + + +@overload +def step(title: _TFunc) -> _TFunc: ... + + +def step(title: Union[str, _TFunc]) -> Union["StepContext", _TFunc]: if callable(title): return StepContext(title.__name__, {})(title) else: