Skip to content

Deprecate possibility to use empty string so that it is interpreted as default value with some standard library keywords #5537

Closed

Description

@pekkaklarck

Some keywords in standard libraries, at least in String and Collections, allow using an empty string so that it is interpreted to mean the same as not using the argument at all. For example, all these usages are equal:

*** Test Cases ***
Example
    Get Slice From List    ${list}    0    2
    Get Slice From List    ${list}    ${EMPTY}    2
    Get Slice From List    ${list}    end=2

This made sense in the early days when tests were created in tables and when the named argument syntax (end=2) wasn't supported. It that usage these were equivalent:

Test Case Keyword Argument Argument Argument
Example Get Slice From List ${list} 0 2
Get Slice From List ${list} 2

In practice the idea was to avoid the need to specify the default value in data. Nowadays the named argument syntax works much better.

This old syntax hasn't bothered much earlier, but now that we are adding type hints to standard libraries, continuing to support it requires using annoying typing like start: int | Literal[""] instead of simpler start: int. I believe that's enough reason to warrant deprecating the syntax in RF 7.4. We can wait at least to RF 8.0, possibly later, before removing it.

Activity

  1. added this to the v7.4 milestone on Nov 4, 2025
  2. self-assigned this
    on Nov 4, 2025
  3. changed the title [-]Deprecate possibility to use empty string so that default value is[/-] [+]Deprecate possibility to use empty string so that it is interpreted as default value with some standard library keywords[/+] on Nov 4, 2025
  4. pekkaklarck commented on Nov 18, 2025

    @pekkaklarck
    MemberAuthor

    I investigated which libraries and keywords are affected:

    • Collections: Get Slice From List and Get Index From List
    • String: Split String, Split String From Right, Split To Lines, Get Substring, Generate Random String,
    • Others: None

    I'll handle Collections now. With String it's probably better to add type hints first.

  5. added a commit that references this issue on Dec 1, 2025
    5c6f27d
  6. pekkaklarck commented on Dec 1, 2025

    @pekkaklarck
    MemberAuthor

    Few more keywords in String are affected.

  7. added a commit that references this issue on Dec 2, 2025
    d8a899c
  8. added a commit that references this issue on Dec 12, 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