Skip to content

Commit d5a7a20

Browse files
starod00mstarod00m
andauthored
Add typehints for step func returning types (#830)
Co-authored-by: starod00m <[email protected]>
1 parent 8063899 commit d5a7a20

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

allure-python-commons/src/_allure.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import wraps
2-
from typing import Any, Callable, TypeVar
2+
from typing import Any, Callable, TypeVar, Union, overload
33

44
from allure_commons._core import plugin_manager
55
from allure_commons.types import LabelType, LinkType, ParameterMode
@@ -161,7 +161,15 @@ def manual():
161161
return Dynamic.label(LabelType.MANUAL, True)
162162

163163

164-
def step(title):
164+
@overload
165+
def step(title: str) -> "StepContext": ...
166+
167+
168+
@overload
169+
def step(title: _TFunc) -> _TFunc: ...
170+
171+
172+
def step(title: Union[str, _TFunc]) -> Union["StepContext", _TFunc]:
165173
if callable(title):
166174
return StepContext(title.__name__, {})(title)
167175
else:

0 commit comments

Comments
 (0)