-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Variable type conversion #3278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This change is backwards compatible because it's possible that someone has used variables that contain |
If this enhancement is implemented, it makes issue #2699 pretty useless. The more I think about it, the more I like this one compared to that one. Mainly because this has so many other benefits than just supporting lists/dicts with embedded arguments. The main questions is, when could this be implemented. RF 3.2 starts to be so much overdue that this issue cannot fit it unless someone else is interested to look at implementing it. RF 3.3. is possible, but also there are so many other high priority features that external help would be highly appreciated. |
We have PR #3385 implementing this so I'll add this tentatively to RF 3.2 scope. That release is so much overdue that I cannot make promises will this issue make into it, though. |
Unfortunately this is too much work for the already overdue RF 3.2. |
I think expected type is only needed when variable is receiving a value. This is special case. |
And ignore type info on embedded keyword var syntax or escape it. |
I'd prefer the
As I already commented above, I don't consider backwards compatibility problems that big. Probably best to allow still using colons in names like |
This conversion is also a bit different from static typing although the syntax points to that. Would this converter be a property of the variable or an external thing? How should each of these behave?
|
It would just be a converter. Creating a variable like |
See issue #3278. User Guide documentation still missing and some cleanup to be done.
User Guide documentation still missing and the code can be enhanced a bit as well. |
- Enhance error reporting with embedded args having invalid type. - Consistent test case naming style. - Some code cleanup. Part of #3278.
Normal type hints should be used instead. Part of #3278.
Don't capitalize "kind" if it is not all lower case to avoid e.g. "FOR loop variable" to be changed to "For loop variable". Related to FOR loop variable conversion that's a missing part of issue #3278.
Missing part of #3278. Includes also enhancements to variable validation during parsing.
Using non-string variables from the command line had a separate issue #2946. That has now been implemented as well and this conversion functionality needs to be documented as part of this issue. |
The current syntax to create an embedded argument with both a type and a custom regexps is |
To some extend related to documenting variable type conversion (#3278).
Earlier syntax was `${name:pattern: type}`, but now it is `${name: type:pattern}`. This is more consistent with the general variable type syntax `${name: type}`. Part of #3278.
I enhanced documentation in 30d87e4. Unfortunately it isn't possible to see generated docs before the final release is out, but here are links to the most relevant places in the documentation source that ought to render somewhat well:
All kind of comments about the docs are welcome and can be written either to here to a thread I'll start about this on the #devel channel on our Slack. This issue can anyway be considered done already now. |
Uh oh!
There was an error while loading. Please reload this page.
RF 3.1 added automatic argument conversion with library keywords using function annotations (#2890), default values (#2932), and some other means. That has worked very well, and it would be nice if something like that would work also with variables defined in test data. We probably could re-use the underlying argument conversion logic which ought to make it relatively easy to implement this. We also got a similar request related to variables passed from the command line #2946.
Automatically converting numbers like
42
and3.14
to actual integers/floats would be handy, even when we already support them as variables like${42}
and${3.14}
. Being able to use datatime objects, bytes, and other types supported by the argument conversion that don't have direct variable alternatives would naturally be even more useful (but also less commonly needed). I would expect this to be most useful with lists and dictionaries and especially with nested list and dicts that cannot easily be constructed in Robot's data.My proposed syntax for this functionality is supporting "type postfix" like
:int
in variable names like this:This syntax is derived from Python's function annotation syntax and also the same syntax that was decided to be used with command line variables in #2946. Created variable names would naturally omit the type suffix and look like
${COUNT}
and${GOOD IDEA}
.In addition to being available in the variable section, the new syntax should also be available also when creating variable otherwise, including in keyword arguments:
There are some design decision still to be made like should
${X:dict}
create aDotDict
instance that allows${X.key}
syntax and how to handle possible backwards incompatibility issues. For most parts the design looks pretty good, though, and I think this would be a valuable addition to Robot Framework. If there's enough interest, we can consider adding this already to RF 3.2 scope. To show your interest, vote with 👍 or 👎 and/or add comments.UPDATE: The final syntax is mostly the same as above, but there needs to be a space after the colon like
${COUNT: int}
. The motivation is making the enhancement less backwards incompatible.The text was updated successfully, but these errors were encountered: