You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support keyword-only arguments in Python 3 libraries #2555
[ ERROR ] Adding keyword 'function' to library 'Library' failed: ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
UPDATE by @pekkaklarck: The above problem that keyword-only arguments prevented using keywords altogether was fixed in RF 3.0.3 by #2627. This issue now covers making it possible to actually use those keyword-only arguments.
changed the title [-]Library (python) with "keyword-only" functions fails to import[/-][+]Support keyword-only arguments in Python 3 libraries[/+]on Mar 1, 2017
Yeah, it would be great to support keyword-only arguments. It hasn't been too high priority because this is a Python 3 feature and thus cannot be used in libs that also need to support Python 2. Keyword-only arguments are really nice, though, so allowing libs that only need to support Python 3 to use them would be great. Those who don't know this feature can take a look at the PEP that proposed them: https://www.python.org/dev/peps/pep-3102/
We should also investigate would it be possible to use keyword-only arguments with Robot's user keywords. That feature requires a separate issue.
Issue #2611 demonstrated that in some cases functions with keyword-only arguments are silently ignored. Let's see could we add support for keyword-only arguments already in 3.0.3. If not, need to at least make sure the problem is always visible.
Cool! Now that #2627 is fixed, keyword-only-arguments don't anymore prevent functions becoming keywords but these arguments are totally ignored. Taking them into use will require changes to ArgumentSpec and to code using it, but I doubt it's going to be overly complicated. If you need any help, comment here or in Slack!
PR #2782 looks great, but we decided to kick RF 3.0.3 out ASAP and only include bug fixes into it. After that we'll start RF 3.1 development and this will be definitely included.
PR #2782 has been merged after few adjustments. There are still few things to do related to this before we can consider this issue done:
Enhance documentation in the User Guide. I think this deserves a bit more text than the current brief note. Should also mention that this is new feature in RF 3.1.
Add kw-only-args support also to Libdoc. At the moment it doesn't document them at all.
Do you @Brian-Williams, or someone else, have time and interest to look at any of the aforementioned topics? I think I'll look adding kw-only-args support to user keywords and the dynamic API next. Probably not a good idea to update the docs in the User Guide before that, but Libdoc enhancements ought to work same way regardless which APIs support kw-only-args.
Activity
[-]Library (python) with "keyword-only" functions fails to import[/-][+]Support keyword-only arguments in Python 3 libraries[/+]pekkaklarck commentedon Mar 1, 2017
Yeah, it would be great to support keyword-only arguments. It hasn't been too high priority because this is a Python 3 feature and thus cannot be used in libs that also need to support Python 2. Keyword-only arguments are really nice, though, so allowing libs that only need to support Python 3 to use them would be great. Those who don't know this feature can take a look at the PEP that proposed them:
https://www.python.org/dev/peps/pep-3102/
We should also investigate would it be possible to use keyword-only arguments with Robot's user keywords. That feature requires a separate issue.
pekkaklarck commentedon May 31, 2017
Issue #2611 demonstrated that in some cases functions with keyword-only arguments are silently ignored. Let's see could we add support for keyword-only arguments already in 3.0.3. If not, need to at least make sure the problem is always visible.
Brian-Williams commentedon Feb 23, 2018
I'll pick this up. I really like using kwo arguments in libraries.
pekkaklarck commentedon Feb 23, 2018
Cool! Now that #2627 is fixed, keyword-only-arguments don't anymore prevent functions becoming keywords but these arguments are totally ignored. Taking them into use will require changes to ArgumentSpec and to code using it, but I doubt it's going to be overly complicated. If you need any help, comment here or in Slack!
pekkaklarck commentedon Mar 16, 2018
PR #2782 looks great, but we decided to kick RF 3.0.3 out ASAP and only include bug fixes into it. After that we'll start RF 3.1 development and this will be definitely included.
Merge branch 'kwo-#2555' of https://github.com/Brian-Williams/robotfr…
Merge branch 'Brian-Williams-kwo-#2555'
pekkaklarck commentedon Jul 7, 2018
PR #2782 has been merged after few adjustments. There are still few things to do related to this before we can consider this issue done:
Enhance documentation in the User Guide. I think this deserves a bit more text than the current brief note. Should also mention that this is new feature in RF 3.1.
Add kw-only-args support also to Libdoc. At the moment it doesn't document them at all.
Add @Brian-Williams to AUTHORS.txt.
Add separate issues to add named-arguments support also to user keywords (Support named-only arguments with user keywords #2896) and to the dynamic library API (Support named-only arguments with dynamic libraries #2897).
Do you @Brian-Williams, or someone else, have time and interest to look at any of the aforementioned topics? I think I'll look adding kw-only-args support to user keywords and the dynamic API next. Probably not a good idea to update the docs in the User Guide before that, but Libdoc enhancements ought to work same way regardless which APIs support kw-only-args.
Libdoc: Support named-only args.
UG: Document named-only args with Python libraries.
Add @Brian-Williams to AUTHORS.txt
pekkaklarck commentedon Jul 18, 2018
All of the tasks listed in my comment above are done and this issue can be considered done as well. Thanks again @Brian-Williams for the PR!