-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,10 @@ def getfullargspec(func): | |
PY2, PY3 = False, True | ||
unicode = str | ||
long = int | ||
try: | ||
from typing import get_type_hints | ||
except ImportError: | ||
get_type_hints = lambda func: func.__annotations__ | ||
|
||
|
||
__all__ = ['RobotRemoteServer', 'stop_remote_server', 'test_remote_server'] | ||
|
@@ -87,6 +91,7 @@ def _register_functions(self, server): | |
server.register_function(self.get_keyword_names) | ||
server.register_function(self.run_keyword) | ||
server.register_function(self.get_keyword_arguments) | ||
server.register_function(self.get_keyword_types) | ||
server.register_function(self.get_keyword_documentation) | ||
server.register_function(self.stop_remote_server) | ||
|
||
|
@@ -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): | ||
if name == 'stop_remote_server': | ||
return {} | ||
return self._library.get_keyword_types(name) | ||
|
||
def get_keyword_documentation(self, name): | ||
if name == 'stop_remote_server': | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. We should add some tests to |
||
if __name__ == "__init__": | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. We should support when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add tests for |
||
elif sys.version_info < (3,): | ||
robot_types = {} | ||
else: | ||
robot_types = get_type_hints(kw) | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Avoid deleting from the From https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
|
||
else: | ||
robot_types[arg_name] = arg_type.__name__ | ||
return robot_types | ||
|
||
def get_keyword_documentation(self, name): | ||
if name == '__intro__': | ||
|
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
toDynamicRemoteLibrary
forget_keyword_types