Repository navigation
Type converter to Robot data - #5379
Conversation
6640d13 to
12f11b5
Compare
0eaffd2 to
a90ad3d
Compare
b78e5b4 to
295d919
Compare
0e7e8c3 to
b213b70
Compare
368268a to
c06f6f9
Compare
pekkaklarck
left a comment
There was a problem hiding this comment.
Looks very good in general, but there seems to be a bug in handling embedded arguments. There are few things to fine-tune as well and TypeInfo.from_variable should get documentation.
92d074e to
1261e8a
Compare
pekkaklarck
left a comment
There was a problem hiding this comment.
Looks great! There are few things still to be enhanced, see the inline comments for details, but I can take care of them.
| Embedded type with custom regular expression 111 | ||
| VAR ${x} 1 | ||
| VAR ${y} 2 | ||
| Embedded ${x} and ${y} |
There was a problem hiding this comment.
Embedded args with variables would deserve its own test. More importantly, variable that's not a string should be tested.
| from pathlib import Path | ||
| from typing import Any, ForwardRef, get_args, get_origin, get_type_hints, Literal, Union | ||
|
|
||
| from robot.variables.search import VariableMatch, search_variable |
There was a problem hiding this comment.
Should be imported from robot.variables.
There was a problem hiding this comment.
Turned out VariableMatch wasn't exposed via robot.variables. It should be.
| for nested in info.nested: | ||
| cls._validate_var_type(nested) | ||
|
|
||
|
|
|
|
||
| def _split_assignment(self, assignment, handle_list_and_dict=True): | ||
| match: VariableMatch = search_variable(assignment, parse_type=True) | ||
| from robot.running import TypeInfo |
There was a problem hiding this comment.
- Import within a method should be on the first line.
matchshouldn't need a type hint becausesearch_variablehas a return type.
|
|
||
| def _convert(self, value, type_): | ||
| from robot.running import TypeInfo | ||
| info = TypeInfo.from_type_hint(type_) |
There was a problem hiding this comment.
Using TypeInfo.from_variable would avoid the need to handle @ and & variables in ListVariableResolver and DictVariableResolver, but because we already have a type here, and needed to construct a variable, that might be more complicated anyway.
| @classmethod | ||
| def from_variable(cls, variable: 'str|VariableMatch', | ||
| handle_list_and_dict: bool = True) -> 'TypeInfo|None': | ||
| """Construct a ``TypeInfo`` based on a variable.""" |
There was a problem hiding this comment.
Here could be an example about the variable syntax and should be a note about this being new in RF 7.3.
Fixes #3278