Skip to content

Commit 4628ad5

Browse files
committed
added RF7 compatibility (Return Types)
Signed-off-by: René <snooz@posteo.de>
1 parent b8c9340 commit 4628ad5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

atest/DynamicTypesAnnotationsLibrary.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def keyword_new_type(self, arg: UserId):
5656
return arg
5757

5858
@keyword
59-
def keyword_define_return_type(self, arg: str) -> None:
59+
def keyword_define_return_type(self, arg: str) -> Union[List[str], str]:
6060
logger.info(arg)
6161
return None
6262

src/robotlibcore.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ def _get_typing_hints(cls, function):
291291
arg_spec = cls._get_arg_spec(function)
292292
all_args = cls._args_as_list(function, arg_spec)
293293
for arg_with_hint in list(hints):
294-
# remove return and self statements
295-
if arg_with_hint not in all_args:
294+
# remove self statements
295+
if arg_with_hint not in [*all_args, "return"]:
296296
hints.pop(arg_with_hint)
297297
return hints
298298

utest/test_get_keyword_types.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_keyword_new_type(lib_types):
8080

8181
def test_keyword_return_type(lib_types):
8282
types = lib_types.get_keyword_types("keyword_define_return_type")
83-
assert types == {"arg": str}
83+
assert types == {"arg": str, 'return': Union[List[str], str]}
8484

8585

8686
def test_keyword_forward_references(lib_types):
@@ -105,7 +105,7 @@ def test_keyword_with_annotation_external_class(lib_types):
105105

106106
def test_keyword_with_annotation_and_default_part2(lib_types):
107107
types = lib_types.get_keyword_types("keyword_default_and_annotation")
108-
assert types == {"arg1": int, "arg2": Union[bool, str]}
108+
assert types == {"arg1": int, "arg2": Union[bool, str], 'return': str}
109109

110110

111111
def test_keyword_with_robot_types_and_annotations(lib_types):
@@ -125,7 +125,7 @@ def test_keyword_with_robot_types_and_bool_annotations(lib_types):
125125

126126
def test_init_args(lib_types):
127127
types = lib_types.get_keyword_types("__init__")
128-
assert types == {"arg": str}
128+
assert types == {"arg": str, "return": type(None)}
129129

130130

131131
def test_dummy_magic_method(lib):
@@ -140,7 +140,7 @@ def test_varargs(lib):
140140

141141
def test_init_args_with_annotation(lib_types):
142142
types = lib_types.get_keyword_types("__init__")
143-
assert types == {"arg": str}
143+
assert types == {"arg": str, "return": type(None)}
144144

145145

146146
def test_exception_in_annotations(lib_types):

utest/test_keyword_builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_types_disabled_in_keyword_deco(lib):
7070

7171
def test_types_(lib):
7272
spec = KeywordBuilder.build(lib.args_with_type_hints)
73-
assert spec.argument_types == {"arg3": str, "arg4": type(None)}
73+
assert spec.argument_types == {"arg3": str, "arg4": type(None), "return": bool}
7474

7575

7676
def test_types(lib):

0 commit comments

Comments
 (0)