Repository navigation
Description
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 interestingI 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:
- Support custom converters for user keyword argument type hints #5783
- Support global scope type converters #4944
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
[-]Allow usage of type `KeywordName`[/-][+]Support `KeywordName` and `KeywordArgument` types as variable types[/+][-]Support `KeywordName` and `KeywordArgument` types as variable types[/-][+]`KeywordName` and `KeywordArgument` types cannot be used as variable types in data[/+]pekkaklarck commentedon Nov 10, 2026
Supporting
KeywordNameandKeywordArgumentsas variable types in data makes sense. I believe we should handle them specially similarly asSecret. 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_NAMESdictionary, but unfortunately importing these types fromrobot.api.typesfails due to recursive import. We probably need to move the implementation of these types torobot.utils.types(or possiblyrobot.utils._types) to avoid that.Secretis already created inrobot.utils.secret, but it's exposed viarobot.api.typesand users should import it from there. If we move these types torobot.utils.types, we should consider movingSecretimplementation there as well.