Skip to content

Add keyword-only argument support #2555 - #2782

Merged
pekkaklarck merged 4 commits into
robotframework:masterfrom
Brian-Williams:kwo-#2555
Jul 7, 2018
Merged

pekkaklarck merged 4 commits into
robotframework:masterfrom
Brian-Williams:kwo-#2555

Conversation

@Brian-Williams

@Brian-Williams Brian-Williams commented Feb 23, 2018 •

Copy link
Copy Markdown

Summary

Addresses #2555.

  • Add dictionary input to _ArgumentParser.parse
  • Change PythonArgumentParser._get_arg_spec to return a dictionary with
    kwonly information
  • Add kwo information to argumentspec and property reqkwargs
  • Added validator for missing keyword only arguments

In mapping I originally did something more complex with DefaultValues,
however since we allow duplicate named inputs and always take the last
one I don't believe anything more complex than converting the
dictionary into a list is required.

Testing

Unit tests passed for 2.7, 3.4-3.6 and pypy3.

Acceptance tests for 2.7 passed with the following parameters: atest/run.py python --exclude no-ciORrequire-screenshot atest/robot

I ran tests against 3.6 for kwonlyarguments: atest/run.py python3 atest/robot/keywords/python_arguments.robot and that succeeds.

@Brian-Williams Brian-Williams changed the title Kwo #2555 Add keyword-only argument support #2555 Feb 23, 2018
@Brian-Williams

Copy link
Copy Markdown
Author

Rebased with robotframework/master to cleanup merge commits.

@pekkaklarck

Copy link
Copy Markdown
Member

I'm torn with this:

  • On a somewhat quick look this PR looks great and the main missing thing seems to be documentation.
  • Yesterday I discussed with @aikarjal from Robot Framework Foundation about forthcoming releases and initially decided to release RF 3.0.3 ASAP (preferably next week) with only bug fixes and then start RF 3.1 development with a goal to release it latest in early June.

Issue #2555 that PR addresses is clearly an enhancement, not a bug, so based on yesterday's discussion we should descope it to RF 3.1. On the other hand, this PR looks good, it's a useful enhancement, and we have never had a general rule not to introduce new features in minor releases.

What do you @Brian-Williams think about this? Would you be fine us getting RF 3.0.3 out ASAP and then returning to this issue/PR?

@Brian-Williams

Copy link
Copy Markdown
Author

I agree this is a "nice to have" not a "must have".

I'm fine with this being pushed out a release.

As for documentation. Do you mean docstrings in the code itself or documented elsewhere? If elsewhere could you point me in the right direction?

@pekkaklarck

Copy link
Copy Markdown
Member

OK, let's try to get RF 3.0.3 out ASAP and get this in right after that.

Something about kw-only-args should be added to the User Guide. Most likely only needs to be documented under the Creating test libraries chapter somewhere.

@Brian-Williams

Brian-Williams commented Jul 3, 2018 •

Copy link
Copy Markdown
Author

Added documentation to the "Creating test libraries" chapter under
"Free keyword arguments with Python".

.. note:: Keyword only arguments are supported as long as you are running
a version of python that supports them (python3, pypy3).

* Add dictionary input to _ArgumentParser.parse
* Change PythonArgumentParser._get_arg_spec to return a dictionary with
kwonly information
* Add kwo information to argumentspec and property reqkwargs
* Added validator for missing keyword only arguments

In mapping I originally did something more complex with DefaultValues,
however since we allow duplicate named inputs and always take the last
one I don't believe anything more complex than converting the
dictionary into a list is required.

Added documentation to the 'Creating test libraries' chapter under
`Providing arguments to test libraries`.
@pekkaklarck

Copy link
Copy Markdown
Member

Going to look at this more closely tomorrow. Are you @Brian-Williams available here or on Slack if I have questions?

@pekkaklarck

Copy link
Copy Markdown
Member

As I've already commented above, this PR is really good. Been testing it locally and making some adjustments and ought to get it merged later today. The biggest changes I've done is moving kw-only-args tests into their own suite (easier to tag them all no-py2) and enhancing error handling. I'll refer to this PR with my commits so those interested in details can look at them.

@pekkaklarck
pekkaklarck merged commit cebed57 into robotframework:master Jul 7, 2018
pekkaklarck added a commit that referenced this pull request Jul 7, 2018
- Better error reporting.
- Tests to own suite, more tests.

See PR #2782.
pekkaklarck added a commit that referenced this pull request Jul 7, 2018
KeywordCallTemplate is not used with Python based static keywords and
thus kw-only-args related changes done in PR #2782 aren't needed there
yet.  Situation changes when kw-only-arg support is added to user
keywords or to the dynamic API.
@pekkaklarck

Copy link
Copy Markdown
Member

Merged the PR, thanks @Brian-Williams, but there are still few more things to do before issue #2555 can be considered done. I'll comment the issue itself about that.

@Brian-Williams

Brian-Williams commented Jul 7, 2018 via email

Copy link
Copy Markdown
Author

@pekkaklarck

Copy link
Copy Markdown
Member

No worries, I haven't been available to look at PRs lately. I try to get the aforementioned tasks today or tomorrow before alpha 2 and holidays.

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