-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Background:
-
Collections has various keywords (e.g.
Sort List,Append To List) that mutate the argument they get and return no value. This works fine when they are used with mutable values (typically lists and dictionaries) and using immutable values (e.g. tuples) currently fails. These failures are not reported too nicely, so the current situation isn't great in this regard. -
We are now adding type hints to Collections (Add annotations to Collections.py #5527) and argument conversion will be done based on them. For example, if we add typing
listto theSort Listkeyword, it can be used with any iterable argument and the argument is converted to a list. The resulting list will then be sorted, but the original value is not affected and thus in practice nothing happens.
Keywords that seem to work but actually do nothing are even worse than keyword that fail with a bad error message, so just adding type hints makes the situation with using these keywords with immutable arguments worse. A simple way to make the situation better is changing these keywords so that they return the value in addition to modifying it. That way these keywords can be used with any iterable/mapping, not on with list/dict.
The change itself is trivial and adding tests isn't hard either. Probably the most challenging task is documenting the behavior so that users understand what's happening. I think it would be best to add a section about this to the general library documentation. A simple note referring to that section can then be added to each affected keyword if needed.