-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement get_keyword_types for non parameterized types #87
base: master
Are you sure you want to change the base?
Conversation
|
||
for arg_name, arg_type in robot_types.items(): | ||
if hasattr(arg_type, '__args__'): | ||
del robot_types[arg_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid deleting from the robot_types
while iterating
From https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
The objects returned by dict.keys(), dict.values() and dict.items() are view objects
Iterating views while adding or deleting entries in the dictionary may raise a RuntimeError or fail to iterate over all entries.
return {} | ||
kw = self._get_keyword(name) | ||
if getattr(kw, "robot_types", None): | ||
robot_types = kw.robot_types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should support when robot_types
is a list since @keyword
supports a list or dict for types
@@ -182,6 +187,11 @@ def get_keyword_arguments(self, name): | |||
if name == 'stop_remote_server': | |||
return [] | |||
return self._library.get_keyword_arguments(name) | |||
|
|||
def get_keyword_types(self, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a dynamic_method
to DynamicRemoteLibrary
for get_keyword_types
return {} | ||
kw = self._get_keyword(name) | ||
if getattr(kw, "robot_types", None): | ||
robot_types = kw.robot_types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add tests for @keyword
's types
to test/utest/test_keyword_decorator.py
and test/libs/KeywordDecorator.py
@@ -322,6 +332,24 @@ def get_keyword_arguments(self, name): | |||
if kwargs: | |||
args.append('**%s' % kwargs) | |||
return args | |||
|
|||
def get_keyword_types(self, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add some tests to test/utest/test_dynamicargsdoctags.py
and test/utest/test_argsdocs.py
Implemented #83
When a type is parametrized like List, Union, Tuple, Literal then the type info is removed. See #84
Python 2 support should be working, but i didn't test it yet.
The import of
get_type_hints
will fall back to__annotations__
on below python 3.5. On python 2 if norobot_types
is set then types will be empty.