traitlets
traitlets copied to clipboard
Changed behaviour since v5.12.0 of `traitlets.Set.set` if value is a string
Before v5.12.0, if the passed value is of type str, the new value hold by the traitlet was a set (or maybe a list?) with a single element of type string. Since 5.12.0, the value of the traitlet is the set of all characters contained in the original string. Hence, #883 introduced a breaking change.
A easy fix would be to change the respective method to:
def set(self, obj: t.Any, value: t.Any) -> None:
if isinstance(value, str):
return super().set(
obj,
set(
[value],
),
)
else:
return super().set(obj, value)