Skip to content

Commit e84be23

Browse files
committed
Drop support for mutable types as Dropdown options
1 parent b0720d9 commit e84be23

File tree

3 files changed

+0
-56
lines changed

3 files changed

+0
-56
lines changed

ipywidgets/widgets/tests/test_interaction.py

-34
Original file line numberDiff line numberDiff line change
@@ -182,40 +182,6 @@ def test_list_tuple_invalid():
182182
print(bad) # because there is no custom message in assert_raises
183183
c = interactive(f, tup=bad)
184184

185-
def test_dict():
186-
for d in [
187-
dict(a=5),
188-
dict(a=5, b='b', c=dict),
189-
]:
190-
c = interactive(f, d=d)
191-
w = c.children[0]
192-
check = dict(
193-
cls=widgets.Dropdown,
194-
description='d',
195-
value=next(iter(d.values())),
196-
options=d,
197-
_options_labels=tuple(d.keys()),
198-
_options_values=tuple(d.values()),
199-
)
200-
check_widget(w, **check)
201-
202-
203-
def test_ordereddict():
204-
from collections import OrderedDict
205-
items = [(3, 300), (1, 100), (2, 200)]
206-
first = items[0][1]
207-
values = OrderedDict(items)
208-
c = interactive(f, lis=values)
209-
assert len(c.children) == 2
210-
d = dict(
211-
cls=widgets.Dropdown,
212-
value=first,
213-
options=values,
214-
_options_labels=("3", "1", "2"),
215-
_options_values=(300, 100, 200),
216-
)
217-
check_widgets(c, lis=d)
218-
219185
def test_iterable():
220186
def yield_values():
221187
yield 3

ipywidgets/widgets/tests/test_widget_selection.py

-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
33

4-
import inspect
5-
import warnings
64
from unittest import TestCase
75

86
from traitlets import TraitError
@@ -15,20 +13,6 @@ class TestDropdown(TestCase):
1513
def test_construction(self):
1614
Dropdown()
1715

18-
def test_deprecation_warning_mapping_options(self):
19-
with warnings.catch_warnings(record=True) as w:
20-
warnings.simplefilter("always")
21-
22-
# Clearing the internal __warningregistry__ seems to be required for
23-
# Python 2 (but not for Python 3)
24-
module = inspect.getmodule(Dropdown)
25-
getattr(module, '__warningregistry__', {}).clear()
26-
27-
Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
28-
assert len(w) > 0
29-
assert issubclass(w[-1].category, DeprecationWarning)
30-
assert "Support for mapping types has been deprecated" in str(w[-1].message)
31-
3216

3317
class TestSelectionSlider(TestCase):
3418

ipywidgets/widgets/widget_selection.py

-6
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ def _make_options(x):
106106
* an iterable of (label, value) pairs
107107
* an iterable of values, and labels will be generated
108108
"""
109-
# Check if x is a mapping of labels to values
110-
if isinstance(x, Mapping):
111-
import warnings
112-
warnings.warn("Support for mapping types has been deprecated and will be dropped in a future release.", DeprecationWarning)
113-
return tuple((str(k), v) for k, v in x.items())
114-
115109
# only iterate once through the options.
116110
xlist = tuple(x)
117111

0 commit comments

Comments
 (0)