Repository navigation
Support KeywordName and KeywordArgument as variable types in data - #5855
Open
gaurav0107 wants to merge 1 commit into
Open
gaurav0107 wants to merge 1 commit into
gaurav0107 wants to merge 1 commit into
Conversation
`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
marked this pull request as ready for review
November 10, 2026 18:27
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5854.
KeywordNameandKeywordArgumentcan now be used as types in data, both with user keyword arguments and when creating variables:Earlier this failed with
Unrecognized type 'KeywordName'.KeywordNamevalues are converted to strings (it is astrsubclass, so the normal string conversion handles it), andKeywordArgumentvalues are passed as-is. This matches the custom converters BuiltIn already uses for these types.Implementation, following the approach in the issue comments:
robot.utils.typesmodule so thatrobot.running.arguments.typeinfocan import them without the recursive import viarobot.api.robot.api.typesre-exports them, and they keep__module__ = "robot.api.types"so they still show up as part of that module in the API docs.keywordnameandkeywordargumentare added toTYPE_NAMES, next tosecret.KeywordArgumentgets a no-op converter, similar toAnyandobject. Without it the type would still be "unrecognized" in data. Because registered converters are documented by Libdoc as standard types,KeywordArgumentalso gets a short type doc inlibdocpkg/standardtypes.py. BuiltIn's own docs don't change because its custom converters take precedence.I didn't move
Secretto the new module, to keep this change small. I can do that here or in a separate PR if you want.Tests:
User keyword: KeywordName and KeywordArgumentinvariables/variable_types.robot, coveringVARand user keyword arguments. It also checks thatKeywordArgumentvalues keep their types. ThreeError In Fileline numbers in the same suite were shifted to match.test_typeinfo.pyfor resolvingsecret,keywordnameandkeywordargumentby name.Ran
python utest/run.py(all pass) andpython atest/run.py --exclude no-ciforvariables/variable_types.robot,keywords/type_conversion,libdocandstandard_libraries/builtin/run_keyword.robot(1058 passed) on Python 3.12. Also ranruff checkand the black + isort steps frominvoke formaton the changed files.🤖 Opened with Superhuman, an open-source contribution agent.