Skip to content

Support keyword-only arguments in Python 3 libraries #2555

Closed

Description

@ilfirin-ms

If library contains function like

function(*variable_arguments, __helper_functions)

import failed with

[ ERROR ] Adding keyword 'function' to library 'Library' failed: ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them

Robot Framework 3.0.2
Python 3.5.2
Ubuntu 16.04 / x86_64 / Linux 4.4.0


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.

Activity

  1. changed the title [-]Library (python) with "keyword-only" functions fails to import[/-] [+]Support keyword-only arguments in Python 3 libraries[/+] on Mar 1, 2017
  2. pekkaklarck commented on Mar 1, 2017

    @pekkaklarck
    Member

    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.

  3. added this to the milestone on May 31, 2017
  4. pekkaklarck commented on May 31, 2017

    @pekkaklarck
    Member

    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.

  5. Brian-Williams commented on Feb 23, 2018

    @Brian-Williams

    I'll pick this up. I really like using kwo arguments in libraries.

  6. pekkaklarck commented on Feb 23, 2018

    @pekkaklarck
    Member

    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!

  7. pekkaklarck commented on Mar 16, 2018

    @pekkaklarck
    Member

    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.

  8. modified the milestones: , on Mar 16, 2018
  9. pekkaklarck commented on Jul 7, 2018

    @pekkaklarck
    Member

    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:

    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.

  10. added
    acknowledge
    on Jul 7, 2018
  11. pekkaklarck commented on Jul 18, 2018

    @pekkaklarck
    Member

    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!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgealpha 2priority: high

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions