Repository navigation
Conversation
fix an issue when using typing function, keyword is not found, refer: https://docs.python.org/3/library/typing.html
pekkaklarck
left a comment
There was a problem hiding this comment.
Looks mostly good for me. Few general comments:
-
Although this is somewhat related to #2555, it would be good to submit a separate issue about the typing problem.
-
Acceptance tests are needed. Please take a a look at
atest/README.rstfor details and let me know if you need help.
| args, varargs, kwargs, defaults = inspect.getargspec(handler) | ||
| if sys.version_info[0] == 2: | ||
| args, varargs, kwargs, defaults = inspect.getargspec(handler) | ||
| varkw = kwargs |
There was a problem hiding this comment.
Use either varkw or kwargs, not both.
|
|
||
| def _get_arg_spec(self, handler): | ||
| args, varargs, kwargs, defaults = inspect.getargspec(handler) | ||
| if sys.version_info[0] == 2: |
There was a problem hiding this comment.
Could also add from robot.utils import PY2 and use PY2 here.
remove varkw, only use kwargs
|
@pekkaklarck Thanks for the comments, my bad, I should not use two different variable names for kwargs. And I have run the atest, seems ok for me. I ran the test on OS X 10.12.5 with Python 2.7.13 installed. |
|
This fix would need new tests too. Could probably add them/it into some existing suite. |
|
The acceptance test is currently running under Python 2, since the typing hint is newly added in 3.5, I don't think it will work in the acceptance test scripts if I add some new tests. |
For Python 3, when I use typing check, Robot Framework always shows me "no keyword with name" error. I found it should be the deprecated method "inspect.getargspec" used in argumentparser.py.
So I put some new code with "inspect.getfullargspec", everything works fine for me now.
This change should be compatible between Python 2 and 3.
Typing hint refer: https://docs.python.org/3.6/library/typing.html
Inspect refer: https://docs.python.org/3.6/library/inspect.html#inspect.getfullargspec