traitlets icon indicating copy to clipboard operation
traitlets copied to clipboard

Changed behaviour since v5.12.0 of `traitlets.Set.set` if value is a string

Open martinclaus opened this issue 2 years ago • 0 comments

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)

martinclaus avatar Nov 12 '23 17:11 martinclaus