Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

Implement get_keyword_types for non parameterized types#87

Open
iDentitY4 wants to merge 1 commit intorobotframework:masterrobotframework/PythonRemoteServer:masterfrom
iDentitY4:masteriDentitY4/PythonRemoteServer:masterCopy head branch name to clipboard
Open

Implement get_keyword_types for non parameterized types#87
iDentitY4 wants to merge 1 commit intorobotframework:masterrobotframework/PythonRemoteServer:masterfrom
iDentitY4:masteriDentitY4/PythonRemoteServer:masterCopy head branch name to clipboard

Conversation

@iDentitY4
Copy link

@iDentitY4 iDentitY4 commented Feb 14, 2024

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 no robot_types is set then types will be empty.


for arg_name, arg_type in robot_types.items():
if hasattr(arg_type, '__args__'):
del robot_types[arg_name]
Copy link

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
Copy link

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

https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#specifying-argument-types-using-keyword-decorator

return []
return self._library.get_keyword_arguments(name)

def get_keyword_types(self, name):
Copy link

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
Copy link

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

args.append('**%s' % kwargs)
return args

def get_keyword_types(self, name):
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.