Skip to content

Change keywords accepting configuration arguments as **config to use named-only arguments instead #5412

Closed

Description

@pekkaklarck

Some keywords accept configuration parameters as **configuration or **config and then read accepted parameters from the resulting dictionary. For example, OperatingSystem has this kind of code:

def append_to_environment_variable(self, name, *values, **config):
    separator = config.pop('separator', os.pathsep)
    if config:
        raise TypeError(...)
    ...

The reason for this configuration approach is that with Python 2 it wasn't possible to have configuration options after *varargs like:

def append_to_environment_variable(self, name, *values, separator=os.pathsep):
    ...

Python 3 supports the above just fine and Robot has supported these named-only arguments for ages as well. We should update keywords so that they use named-only arguments instead of **config for the following reasons:

Based on my search these keywords need to be updated:

  • OperatingSystem.append_to_environment_variable
  • BuiltIn.should_contain_any
  • BuiltIn.should_not_contain_any
  • Process.run_process
  • Process.start_process

It would be good to get these updated already in RF 7.3 so that people interested in adding type hints (#5373) in RF 7.4 don't need to wait. Three first ought to be easy to fix, but the last two are a little bit more complicated, because they also accept environment variables freely using format env:name=value. They thus need to continue to accept **extra_env or something like that. If that gets too complicated, fixing Process keywords can wait for RF 7.4.

Activity

  1. added this to the v7.3 milestone on Apr 24, 2025
  2. self-assigned this
    on Apr 24, 2025
  3. added a commit that references this issue on Apr 24, 2025
    4c8f33e
  4. changed the title [-]Change keywords accepting configuration parameters as `**configuration` to use named-only arguments instead[/-] [+]Change keywords accepting configuration parameters as `**config` to use named-only arguments instead[/+] on Apr 24, 2025
  5. changed the title [-]Change keywords accepting configuration parameters as `**config` to use named-only arguments instead[/-] [+]Change keywords accepting configuration arguments as `**config` to use named-only arguments instead[/+] on Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions