-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Argument conversion and validation with non-string argument values #3735
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 also makes it easy to add conversion to other non-string arguments as discussed in #3735.
Conversion logic will be changed like this:
|
1. More conversions: - Boolean: int, float and None are accepted without conversion - Decimal: int and float are converted - Bytes/ByteArray: bytearray/bytes is converted - List/Tuple: tuple/list is converted - Set/FrozenSet: frozenset/set, list, tuple and dict are converted 2. Other argument types cause conversion error.
This issue ought to be done except for updating the User Guide. That will be done soonish when all type conversion enhancements are done. |
This also makes it easy to add conversion to other non-string arguments as discussed in robotframework#3735.
1. More conversions: - Boolean: int, float and None are accepted without conversion - Decimal: int and float are converted - Bytes/ByteArray: bytearray/bytes is converted - List/Tuple: tuple/list is converted - Set/FrozenSet: frozenset/set, list, tuple and dict are converted 2. Other argument types cause conversion error.
- Union support. Fixes robotframework#3738. - Conversion with non-string values. Fixes robotframework#3735. - Conversion to string. Fixes robotframework#3736. - None as an alias for NoneType. Fixes robotframework#3739. - Stricter None conversion. Fixes robotframework#3729.
When argument conversion was added in RF 3.1 (#2890, #2947, #2932) a decision was made that conversion is done only if the given argument is a Unicode string. This approach has some limitations and a decision has been made to support conversion also with other argument types.
The problem here is that there is an unlimited amount of types users could use and handling all cases sanely is likely not easy. There are, however, many simple and useful cases like converting an integer to a float if a keyword accepts
arg: float
and accepting numbers witharg: timedelta
.One important decision to be made is handling types we cannot convert. For example, if we have
arg: int
and it is called withNone
, what should we do. We can either pass the given argument as-is or, probably better, make it an error. Making this an error is backwards incompatible change, though.The text was updated successfully, but these errors were encountered: