Skip to content

Commit 5536885

Browse files
committed
Make the selection widgets mapping options error more helpful.
1 parent 58adde2 commit 5536885

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

docs/source/user_migration_guides.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ For these, it is no longer possible to use `dict`s or other mapping types as val
4848
`options` trait. Using mapping types in this way has been deprecated since version 7.4, and
4949
will now raise a `TypeError`.
5050

51-
Suggested migration: Clean up the `options` use. The following snippet can be used to convert
52-
a `dict` to the new format: `w.options = tuple((str(k), v) for k, v in your_dict.items())`.
51+
Suggested migration: Instead of using a dict `my_dict` as options, use `my_dict.items()`, which returns the items in `my_dict` as key-value pairs. For example, `Select(options=my_dict.items())`.
5352

5453
#### Description Sanitization
5554

python/ipywidgets/ipywidgets/widgets/widget_selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _make_options(x):
112112
* an iterable of values, and labels will be generated
113113
"""
114114
if isinstance(x, Mapping):
115-
raise TypeError("options must be a list of values or a list of (label, value) tuples")
115+
raise TypeError("options must be a iterable of values or of (label, value) pairs. If x is your Mapping, use x.items() for the options.")
116116

117117
# only iterate once through the options.
118118
xlist = tuple(x)

0 commit comments

Comments
 (0)