Skip to content

User keyword type conversion between int/float and bool not working #5622

Description

@Mercury37

Issue

When defining a user keyword with an argument that is typehinted as int, I expect that values are either converted to the type int or rejected. This works with e.g. strings or floats, but bool values appear to be accepted without conversion.
The same thing seems to happen in the reverse case, when passing int/float into a user keyword argument typehinted as bool.

Example

*** Test Cases ***
Example Test
    Log As Int    ${0}
    Log As Int    0
    Log As Int    ${FALSE}
    Log As Int    ${TRUE}
    Log As Int    ${3.0}

    Log To Console    ---------

    Log As Bool    ${0}
    Log As Bool    0
    Log As Bool    ${FALSE}
    Log As Bool    ${TRUE}
    Log As Bool    ${3.0}


*** Keywords ***
Log As Int
    [Arguments]    ${value: int}
    Log To Console    ${value} ${{type(${value})}}

Log As Bool
    [Arguments]    ${value: bool}
    Log To Console    ${value} ${{type(${value})}}

Relevant console output:

0 <class 'int'>
0 <class 'int'>
False <class 'bool'>
True <class 'bool'>
3 <class 'int'>
---------
0 <class 'int'>
False <class 'bool'>
False <class 'bool'>
True <class 'bool'>
3.0 <class 'float'>

Versions

Python 3.13.0
Robot Framework 7.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions