Skip to content

Variable type conversion (#3278) - #3385

Closed
AirTruc wants to merge 1 commit into
robotframework:masterfrom
AirTruc:issue/3278_variable_type_conversion
Closed

AirTruc wants to merge 1 commit into
robotframework:masterfrom
AirTruc:issue/3278_variable_type_conversion

Conversation

@AirTruc

@AirTruc AirTruc commented Nov 21, 2019

Copy link
Copy Markdown
Contributor

Hi,
This PR implements functionalities of issues #3278
The functionalities implemented are :

  • type in name of arguments
  • type in name of embedded arguments
  • type in name of assigned variables
  • type in CLI variables
  • type in name of define variables
  • type in name of variable use with Set Test Variable

Moreover, the supported type are : int, float, string, boolean, date, datetime, timedelta, list and dict.

Don't hesitate to challenge the code, the development was difficult for me.

Best Regards,

@pekkaklarck

Copy link
Copy Markdown
Member

Due to me being somewhat busy and there being lot of changes, I don't have time to review this right now. I'll add the underlying issue to RF 3.2 scope so that I won't forget about it. That said, RF 3.2 is already overdue and I definitely want it out this year, so there's a change this won't make it into it anyway. I'll do my best.

@pekkaklarck

pekkaklarck commented Dec 4, 2019 •

Copy link
Copy Markdown
Member

I went through the code quickly and realized this is even bigger change than I expected. RF 3.2 is already so much overdue that unfortunately this needs to be descoped. This is a great feature for RF 3.3, but I cannot promise when its active development starts, hopefully sometime 2020.

I won't do a detailed review to this PR now, but I'll go through the code again and add comments to places that I think should be changed. Because this is such a huge feature, I would also recommend splitting it into several PRs implementing independent features separately. These independent features could be:

  • User keyword argument type conversion. Could use lot of the existing library keyword type conversion logic, just needed to parse type information from user keyword arguments.
  • Conversion with embedded arguments. There's an extra challenge because they already support name:pattern syntax and adding name:type and name:pattern:type support requires thinking how to separate : used for different purposes. This gets even "funnier" when the pattern may also contain a literal colon.
  • Conversion in the Variables section.
  • Conversion when assigning a variable based on keyword return value.
  • Conversion when using Set Global/Suite/Test/Local Variable.
  • Possible general enhancements to conversion logic such as support for new types. If there are generally useful enhancements, separate issues should be submitted about them.

else:
self._add_arg(spec, arg, kw_only_args)
if type_:
self._add_type_to_arg(spec, arg, type_)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to get the type information in the beginning? Wouldn't it be easier to just enhance _add_arg so that it can check does the name have embedded type information and then act accordingly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is necessary because _split_args_and_types remove type in args. If we don't split in begin we have problem with kwargs and vargs when the argname will be 'arg:type'

Comment thread src/robot/running/arguments/embedded.py Resolved
Comment thread src/robot/variables/tablesetter.py Resolved
Comment thread src/robot/variables/tablesetter.py Resolved
Comment thread src/robot/variables/typeconverters.py Resolved
Comment thread src/robot/variables/typeconverters.py Resolved
@AirTruc

AirTruc commented Jan 26, 2020

Copy link
Copy Markdown
Contributor Author

@pekkaklarck I will split the merge request but what is a process? I will push my modification in this branch and i keep my merge request or I create a new branch and new merge request?
For the list of independent features, do we write it in issues or do we create a issue for each features?

@AirTruc
AirTruc force-pushed the issue/3278_variable_type_conversion branch from 0b77b92 to f92d296 Compare March 27, 2020 21:22
@AirTruc
AirTruc force-pushed the issue/3278_variable_type_conversion branch from f92d296 to 092d568 Compare March 27, 2020 22:15
@codecov-io

codecov-io commented Mar 27, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #3385 into master will decrease coverage by 0.68%.
The diff coverage is 38.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3385      +/-   ##
==========================================
- Coverage   73.64%   72.96%   -0.67%     
==========================================
  Files         198      198              
  Lines       16377    16073     -304     
  Branches     2633     2637       +4     
==========================================
- Hits        12059    11726     -333     
- Misses       3880     3903      +23     
- Partials      438      444       +6     
Impacted Files Coverage Δ
src/robot/running/arguments/argumentparser.py 63.08% <38.89%> (-4.71%) ⬇️
src/robot/utils/robottypes3.py 87.18% <0.00%> (-7.69%) ⬇️
src/robot/utils/etreewrapper.py 77.03% <0.00%> (-5.40%) ⬇️
src/robot/utils/dotdict.py 94.88% <0.00%> (-5.12%) ⬇️
src/robot/conf/settings.py 68.33% <0.00%> (-3.69%) ⬇️
src/robot/libraries/BuiltIn.py 25.05% <0.00%> (-2.65%) ⬇️
src/robot/running/usererrorhandler.py 74.08% <0.00%> (-2.59%) ⬇️
src/robot/utils/robotpath.py 64.16% <0.00%> (-1.88%) ⬇️
src/robot/errors.py 67.11% <0.00%> (-1.83%) ⬇️
src/robot/running/handlers.py 72.65% <0.00%> (-1.72%) ⬇️
... and 52 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0869572...092d568. Read the comment docs.

@pekkaklarck

Copy link
Copy Markdown
Member

Sorry for us dropping the ball with this PR @LeConTesteur. I don't remember what happened to it, but it doesn't make sense to resurrect it anymore. Reasons are:

  • There are plenty of conflicts.
  • It only implements conversion with user keyword arguments.
  • PR Type converter to Robot data #5379 implements that in addition to other variable conversions.

@pekkaklarck pekkaklarck closed this Apr 7, 2025
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.

3 participants