Skip to content

Commit

Permalink
added RF7 compatibility (Return Types)
Browse files Browse the repository at this point in the history
Signed-off-by: René <[email protected]>
  • Loading branch information
Snooz82 committed Nov 18, 2023
1 parent b8c9340 commit 4628ad5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion atest/DynamicTypesAnnotationsLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def keyword_new_type(self, arg: UserId):
return arg

@keyword
def keyword_define_return_type(self, arg: str) -> None:
def keyword_define_return_type(self, arg: str) -> Union[List[str], str]:
logger.info(arg)
return None

Expand Down
4 changes: 2 additions & 2 deletions src/robotlibcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def _get_typing_hints(cls, function):
arg_spec = cls._get_arg_spec(function)
all_args = cls._args_as_list(function, arg_spec)
for arg_with_hint in list(hints):
# remove return and self statements
if arg_with_hint not in all_args:
# remove self statements
if arg_with_hint not in [*all_args, "return"]:
hints.pop(arg_with_hint)
return hints

Expand Down
8 changes: 4 additions & 4 deletions utest/test_get_keyword_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_keyword_new_type(lib_types):

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


def test_keyword_forward_references(lib_types):
Expand All @@ -105,7 +105,7 @@ def test_keyword_with_annotation_external_class(lib_types):

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


def test_keyword_with_robot_types_and_annotations(lib_types):
Expand All @@ -125,7 +125,7 @@ def test_keyword_with_robot_types_and_bool_annotations(lib_types):

def test_init_args(lib_types):
types = lib_types.get_keyword_types("__init__")
assert types == {"arg": str}
assert types == {"arg": str, "return": type(None)}


def test_dummy_magic_method(lib):
Expand All @@ -140,7 +140,7 @@ def test_varargs(lib):

def test_init_args_with_annotation(lib_types):
types = lib_types.get_keyword_types("__init__")
assert types == {"arg": str}
assert types == {"arg": str, "return": type(None)}


def test_exception_in_annotations(lib_types):
Expand Down
2 changes: 1 addition & 1 deletion utest/test_keyword_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_types_disabled_in_keyword_deco(lib):

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


def test_types(lib):
Expand Down

0 comments on commit 4628ad5

Please sign in to comment.