Skip to content

Mistyped named arguments interpreted as positional arguments #4693

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
okleinke opened this issue Mar 15, 2023 · 2 comments
Closed

Mistyped named arguments interpreted as positional arguments #4693

okleinke opened this issue Mar 15, 2023 · 2 comments

Comments

@okleinke
Copy link

Hi,

Many times I have encountered a problem with wrongly spelled named arguments being interpreted as position arguments. Especially when the casing/spelling of arguments change (are changed by colleagues). Here is an example:

*** Test Cases ***
TC
    KW
    KW  named1=1
    KW  named_1=1
    KW  Named2=1

*** Keywords ***
KW
    [Arguments]    ${named1}=1  ${named2}=2
    Log To Console    ${\n}Got named1: "${named1}"
    Log To Console    Got named2: "${named2}"

And the output below. Problematic are the last and second to last case.

Got named1: "1"
Got named2: "2"

Got named1: "1"
Got named2: "2"

Got named1: "named_1=1"
Got named2: "2"

Got named1: "Named2=1"
Got named2: "2"

I propose the following solution: Log/print a warning if

  • a positional argument contains a "=", and
  • the part that is left of the "=" symbol is similar to the name of a named argument.

Similarity could be determined, for example, using simplified/modified levenshtein distance.

I think this is the location where such a check could be implemented, although I'm not sure whether warnings can be logged by this class (using import warnings?):

@pekkaklarck
Copy link
Member

This is a real problem, but hard to solve without breaking backwards compatibility massively. The main problem is that = is a pretty commonly used in normal arguments. If we'd always interpret xxx=yyy to mean named argument usage with xxx as the name, that would be massively backwards incompatible and even reporting a warning would be very annoying. If we were to do something like that, it would need to be controlled with a command line option.

I believe we need to return to this at some point.

@pekkaklarck
Copy link
Member

#5431 brought this up again. I'll close this as its duplicate and comment it when I have a bit more time

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

No branches or pull requests

2 participants