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
BuiltIn: Explicitly mark arguments that are positional-only #5025
Robot Framework Version: 7.0 (also occurs on 6.1.1)
Python interpreter version: 3.11.3
OS: Windows 10 and RHEL
Run Keyword and Expect Error fails when expected_error is a named argument (expected_error=thing) it will look for an error beginning with the string expected_error=
Example passing and failing TC using positional and named arg respectively
*** Test Cases ***
TestExpectErrorPositionalArg
Run Keyword And Expect Error
... REGEXP:^.abc123.$
... Fail
... msg=Error message including substring abc123 to be matched against
TestExpectErrorNamedArg
Run Keyword And Expect Error
... expected_error=REGEXP:^.abc123.$
... Fail
... msg=Error message including substring abc123 to be matched against
Error message from test2:
Expected error '**expected_error=**REGEXP:^.abc123.$' but got 'Error message including substring abc123 to be matched against'.
You can see that it is searching for a literal string beginning with expected_error= and REGEX prefix isn't considered to be at beginning of line so isn't parsed.
I think as written the _error_is_expected function doesn't handle named variables correctly.
changed the title [-]Run Keyword and Expect Error fails with named arguments[/-][+]Document that `Run Keyword` variants do not support named arguments [/+]on May 20, 2025
Normal arguments accepted by various run keyword variants are In practice positional-only. Instead of mentioning that in the documentation, it is better to explicitly mark these arguments to be positional-only. That automatically adds the information to Libdoc HTML outputs, allows IDEs to warn about using these arguments as named arguments, and so on.
changed the title [-]Document that `Run Keyword` variants do not support named arguments [/-][+]Mark normal arguments accepted by `Run Keyword` and its variants explicitly positional-only[/+]on Aug 27, 2025
The root cause is exactly the same as in #5235. When fixing that, I decided to just document the behavior with some keywords that were considered more likely to be used with named arguments. I had noticed that other keywords may be affected, but didn't consider adding a note to all their docs worth the effort.
This particular issue demonstrates that there can be confusion also with other keywords. Adding a note to all docs would be quite a big task, but adding the positional-only marker / to signatures is luckily simpler.
changed the title [-]Mark normal arguments accepted by `Run Keyword` and its variants explicitly positional-only[/-][+]BuiltIn: Mark arguments that are positional only explicitly[/+]on Aug 27, 2025
changed the title [-]BuiltIn: Mark arguments that are positional only explicitly[/-][+]BuiltIn: Explicitly mark arguments that are positional-only [/+]on Aug 27, 2025
Making arguments explicitly positional-only caused problems when these method are used from Python. With keywords accepting *args it hasn't been in practice possible to use arguments like name=value even earlier, but there are some keywords where that syntax used to work. For example, BuiltIn().get_variable_value("${x}", default="value") used to work, but nowadays that syntax causes an error and BuiltIn().get_variable_value("${x}", "value") needs to be used instead. This is rather annoying and we need to decide how to handle. Options are:
Consider the current behavior fine. Usage from Python is not that common and using "value" instead of default="value" isn't that bad.
Revert the change with keywords not accepting *args. Then we should document that these keywords don't support the ´name=value` syntax when used from Python.
Try to make keywords that don't accept *args to work with the name=value syntax also from Python. This would be the best solution, but it may not be easy.
Regardless what we do, RF 7.4 release notes need to be updated so that this issue is mentioned under backwards incompatible changes.
Activity
pekkaklarck commentedon May 20, 2025
expected_errorcannot be specified as a named argument. OtherRun Keywordvariants have the same limitation. This needs to be documented[-]Run Keyword and Expect Error fails with named arguments[/-][+]Document that `Run Keyword` variants do not support named arguments [/+]pekkaklarck commentedon May 20, 2025
Keywords executed by these keywords support named args. Mixing them with arguments used by these keywords themselves wouldn't work.
pekkaklarck commentedon Aug 27, 2025
Normal arguments accepted by various run keyword variants are In practice positional-only. Instead of mentioning that in the documentation, it is better to explicitly mark these arguments to be positional-only. That automatically adds the information to Libdoc HTML outputs, allows IDEs to warn about using these arguments as named arguments, and so on.
[-]Document that `Run Keyword` variants do not support named arguments [/-][+]Mark normal arguments accepted by `Run Keyword` and its variants explicitly positional-only[/+]pekkaklarck commentedon Aug 27, 2025
The root cause is exactly the same as in #5235. When fixing that, I decided to just document the behavior with some keywords that were considered more likely to be used with named arguments. I had noticed that other keywords may be affected, but didn't consider adding a note to all their docs worth the effort.
This particular issue demonstrates that there can be confusion also with other keywords. Adding a note to all docs would be quite a big task, but adding the positional-only marker
/to signatures is luckily simpler.[-]Mark normal arguments accepted by `Run Keyword` and its variants explicitly positional-only[/-][+]BuiltIn: Mark arguments that are positional only explicitly[/+][-]BuiltIn: Mark arguments that are positional only explicitly[/-][+]BuiltIn: Explicitly mark arguments that are positional-only [/+]BuiltIn: Explicitly mark positional-only arguments
pekkaklarck commentedon Dec 17, 2025
Making arguments explicitly positional-only caused problems when these method are used from Python. With keywords accepting
*argsit hasn't been in practice possible to use arguments likename=valueeven earlier, but there are some keywords where that syntax used to work. For example,BuiltIn().get_variable_value("${x}", default="value")used to work, but nowadays that syntax causes an error andBuiltIn().get_variable_value("${x}", "value")needs to be used instead. This is rather annoying and we need to decide how to handle. Options are:"value"instead ofdefault="value"isn't that bad.*args. Then we should document that these keywords don't support the ´name=value` syntax when used from Python.*argsto work with thename=valuesyntax also from Python. This would be the best solution, but it may not be easy.Regardless what we do, RF 7.4 release notes need to be updated so that this issue is mentioned under backwards incompatible changes.
Mention #5025 under backwards incompatible changes
Mention that problems caused by #5025 will be fixed in RF 7.4.1.