Skip to content

Support argument conversion to string #3736

Closed
Closed

Description

@pekkaklarck

Currently we don't any argument conversion if an argument has string as its type like arg: str. The main reason is that at the moment we only convert the given argument if its type is a string, but the plan is to change that #3735. Implementing this change would avoid problems like robotframework/SeleniumLibrary#1021.

The only design decision related to this is what argument types to convert. All Python objects have a string representation, so if you have a keyword like

def keyword(arg: str):
    print(arg, type(arg))

and call it like

Keyword    ${NONE}

and we convert all arguments, the keyword gets string None as an argument. Other options would be making this situation with None an error and passing None as-is without conversion. I got a feeling it's best to just convert all arguments, including None.

If we convert everything, including ´None`, it means that if we'd have keyword

def keyword(arg: str = None):
    print(arg, type(arg))

and call it like above, the keyword would still get string None as the argument. I guess that's OK because the argument has an explicit str type even though it has None as the default value.

Activity

  1. added this to the v4.0 milestone on Oct 22, 2020
  2. pekkaklarck commented on Oct 25, 2020

    @pekkaklarck
    MemberAuthor

    This will be implemented so that all arguments are converted the type is given explicitly using annotation (e.g. arg: str) or decorator (e.g. @keyword(types={'arg': str}). If the type if got from the default value (e.g. `arg='foo'), conversion is not done.

  3. added a commit that references this issue on Oct 26, 2020
  4. added a commit that references this issue on Nov 2, 2020
    24cec81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions