Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pekkaklarck opened this issue Apr 24, 2025 · 0 comments

Comments

@pekkaklarck
Copy link
Member

pekkaklarck commented Apr 24, 2025

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.

@pekkaklarck pekkaklarck added this to the v7.3 milestone Apr 24, 2025
@pekkaklarck pekkaklarck self-assigned this Apr 24, 2025
pekkaklarck added a commit that referenced this issue Apr 24, 2025
`Process.run_process` signature will change as part of #5412. Better
to use a custom library in Libdoc tests instead.
@pekkaklarck pekkaklarck 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 Apr 24, 2025
@pekkaklarck pekkaklarck 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 Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant