Skip to content

KeywordName and KeywordArgument types cannot be used as variable types in data #5854

Description

@Lakitna

Background

With the new type system, we can do a bunch of things we could never do in the past. This has been great!

One of these capabilities includes the detection of keywords used by other keywords. Basic example:

Run Keyword    Log    Hello world!

The keyword Log is used by the keyword Run Keyword.

When writing tools, it is quite difficult to determine if Log should be treated as a keyword or as a string. But types to the rescue! Now we can check if the first argument of the parent keyword (Run Keyword) is typed as KeywordName. This is a type provided in the public API of Robot. This allows tools to say "Log is a keyword" with certainty.

This allows our tools to be better. Tools that can use this include, but are not limited to:

  • RobotCode (syntax highlighting, go to definition, count keyword uses reliably, etc)
  • RoboCop (rules targeting keywords passed to other keywords)

Issue

There is one part of the puzzle missing though: I can't use the KeywordName type in a keyword defined in the Robot language.

When I copy the type signature of Builtin.Run Keyword to a custom keyword:

My Custom Keyword
    [Arguments]    ${kw: KeywordName}    @{args: KeywordArgument}
    # Do something interesting

I get runtime errors:

Invalid argument specification: Multiple errors:
- Invalid argument '${kw: KeywordName}': Unrecognized type 'KeywordName'.
- Invalid argument '@{args: KeywordArgument}': Unrecognized type 'KeywordArgument'.

Proposal

One of two:

Option 1: Arbitrary Python types

Give users some way of importing arbitrary Python types that can be used in the Robot language for type definition. This allows users to import the types from the Robot public API. But also complex library types, custom library types, and data structure types.

This would be a big feature that may take a long time to design and implement. Would be very flexible though.

Related to existing issues:

Option 2: Treat KeywordName like Secret

Make KeywordName a special Robot type that gets preferential treatment over other types. Basically what already happens with Secret.

Optional: Do the same with KeywordArgument. Though maybe KeywordArgument can simply be mapped to Any.

Activity

  1. changed the title [-]Allow usage of type `KeywordName`[/-] [+]Support `KeywordName` and `KeywordArgument` types as variable types[/+] on Nov 10, 2026
  2. added this to the v7.6 milestone on Nov 10, 2026
  3. added theissue type on Nov 10, 2026
  4. changed the title [-]Support `KeywordName` and `KeywordArgument` types as variable types[/-] [+]`KeywordName` and `KeywordArgument` types cannot be used as variable types in data[/+] on Nov 10, 2026
  5. pekkaklarck commented on Nov 10, 2026

    @pekkaklarck
    Member

    Supporting KeywordName and KeywordArguments as variable types in data makes sense. I believe we should handle them specially similarly as Secret. It's much easier to just use ${name: KeywordName} than to require users to register these types somehow or to use something like ${name: robot.api.types.KeywordName}.

    Implementing this shouldn't require more than adding these types to the robot.running.arguments.typeinfo.TYPE_NAMES dictionary, but unfortunately importing these types from robot.api.types fails due to recursive import. We probably need to move the implementation of these types to robot.utils.types (or possibly robot.utils._types) to avoid that. Secret is already created in robot.utils.secret, but it's exposed via robot.api.types and users should import it from there. If we move these types to robot.utils.types, we should consider moving Secret implementation there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions