Skip to content

Support KeywordName and KeywordArgument as variable types in data - #5855

Open
gaurav0107 wants to merge 1 commit into
robotframework:masterfrom
gaurav0107:fix/5854-keywordname-and-keywordargument-types-ca
Open

gaurav0107 wants to merge 1 commit into
robotframework:masterfrom
gaurav0107:fix/5854-keywordname-and-keywordargument-types-ca

Conversation

@gaurav0107

Copy link
Copy Markdown

Fixes #5854.

KeywordName and KeywordArgument can now be used as types in data, both with user keyword arguments and when creating variables:

*** Keywords ***
My Run Keyword
    [Arguments]    ${name: KeywordName}    @{args: KeywordArgument}
    Run Keyword    ${name}    @{args}

Earlier this failed with Unrecognized type 'KeywordName'. KeywordName values are converted to strings (it is a str subclass, so the normal string conversion handles it), and KeywordArgument values are passed as-is. This matches the custom converters BuiltIn already uses for these types.

Implementation, following the approach in the issue comments:

  • The types are now implemented in a new robot.utils.types module so that robot.running.arguments.typeinfo can import them without the recursive import via robot.api. robot.api.types re-exports them, and they keep __module__ = "robot.api.types" so they still show up as part of that module in the API docs.
  • keywordname and keywordargument are added to TYPE_NAMES, next to secret.
  • KeywordArgument gets a no-op converter, similar to Any and object. Without it the type would still be "unrecognized" in data. Because registered converters are documented by Libdoc as standard types, KeywordArgument also gets a short type doc in libdocpkg/standardtypes.py. BuiltIn's own docs don't change because its custom converters take precedence.

I didn't move Secret to the new module, to keep this change small. I can do that here or in a separate PR if you want.

Tests:

  • New acceptance test User keyword: KeywordName and KeywordArgument in variables/variable_types.robot, covering VAR and user keyword arguments. It also checks that KeywordArgument values keep their types. Three Error In File line numbers in the same suite were shifted to match.
  • Unit tests in test_typeinfo.py for resolving secret, keywordname and keywordargument by name.

Ran python utest/run.py (all pass) and python atest/run.py --exclude no-ci for variables/variable_types.robot, keywords/type_conversion, libdoc and standard_libraries/builtin/run_keyword.robot (1058 passed) on Python 3.12. Also ran ruff check and the black + isort steps from invoke format on the changed files.


🤖 Opened with Superhuman, an open-source contribution agent.

`KeywordName` and `KeywordArgument` can now be used as types with
variables and user keyword arguments like `${name: KeywordName}` and
`@{args: KeywordArgument}`. `KeywordName` values are converted to
strings and `KeywordArgument` values are not converted at all.

The types are implemented in `robot.utils.types` to avoid recursive
imports, but they are still exposed via `robot.api.types` and should be
imported from there.

Fixes robotframework#5854.
@gaurav0107
gaurav0107 marked this pull request as ready for review November 10, 2026 18:27

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant