Skip to content

Commit af90227

Browse files
authored
Merge pull request #2655 from jasongrout/deprecations
Remove some more py3-related warnings and deprecations
2 parents 9f15bd7 + 372457b commit af90227

File tree

2 files changed

+3
-116
lines changed

2 files changed

+3
-116
lines changed

ipywidgets/widgets/interaction.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,11 @@ def _yield_abbreviations_for_parameter(param, kwargs):
117117
"""Get an abbreviation for a function parameter."""
118118
name = param.name
119119
kind = param.kind
120-
ann = param.annotation
121120
default = param.default
122121
not_found = (name, empty, empty)
123122
if kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.KEYWORD_ONLY):
124123
if name in kwargs:
125124
value = kwargs.pop(name)
126-
elif ann is not empty:
127-
warn("Using function annotations to implicitly specify interactive controls is deprecated. Use an explicit keyword argument for the parameter instead.", DeprecationWarning)
128-
value = ann
129125
elif default is not empty:
130126
value = default
131127
else:
@@ -246,7 +242,7 @@ def update(self, *args):
246242
except Exception as e:
247243
ip = get_ipython()
248244
if ip is None:
249-
self.log.warn("Exception in interact callback: %s", e, exc_info=True)
245+
self.log.warning("Exception in interact callback: %s", e, exc_info=True)
250246
else:
251247
ip.showtraceback()
252248
finally:

ipywidgets/widgets/tests/test_interaction.py

Lines changed: 2 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from traitlets import TraitError
1515
from ipywidgets import (interact, interact_manual, interactive,
1616
interaction, Output)
17-
from ipython_genutils.py3compat import annotate
1817

1918
#-----------------------------------------------------------------------------
2019
# Utility stuff
@@ -249,7 +248,8 @@ def test_iterable_tuple():
249248
check_widgets(c, lis=d)
250249

251250
def test_mapping():
252-
from collections import Mapping, OrderedDict
251+
from collections.abc import Mapping
252+
from collections import OrderedDict
253253
class TestMapping(Mapping):
254254
def __init__(self, values):
255255
self.values = values
@@ -276,115 +276,6 @@ def items(self):
276276
)
277277
check_widgets(c, lis=d)
278278

279-
280-
def test_defaults():
281-
@annotate(n=10)
282-
def f(n, f=4.5, g=1):
283-
pass
284-
285-
c = interactive(f)
286-
check_widgets(c,
287-
n=dict(
288-
cls=widgets.IntSlider,
289-
value=10,
290-
),
291-
f=dict(
292-
cls=widgets.FloatSlider,
293-
value=4.5,
294-
),
295-
g=dict(
296-
cls=widgets.IntSlider,
297-
value=1,
298-
),
299-
)
300-
301-
def test_default_values():
302-
@annotate(n=10, f=(0, 10.), g=5, h=OrderedDict([('a',1), ('b',2)]), j=['hi', 'there'])
303-
def f(n, f=4.5, g=1, h=2, j='there'):
304-
pass
305-
306-
c = interactive(f)
307-
check_widgets(c,
308-
n=dict(
309-
cls=widgets.IntSlider,
310-
value=10,
311-
),
312-
f=dict(
313-
cls=widgets.FloatSlider,
314-
value=4.5,
315-
),
316-
g=dict(
317-
cls=widgets.IntSlider,
318-
value=5,
319-
),
320-
h=dict(
321-
cls=widgets.Dropdown,
322-
options=OrderedDict([('a',1), ('b',2)]),
323-
value=2
324-
),
325-
j=dict(
326-
cls=widgets.Dropdown,
327-
options=('hi', 'there'),
328-
value='there'
329-
),
330-
)
331-
332-
def test_default_out_of_bounds():
333-
@annotate(f=(0, 10.), h={'a': 1}, j=['hi', 'there'])
334-
def f(f='hi', h=5, j='other'):
335-
pass
336-
337-
c = interactive(f)
338-
check_widgets(c,
339-
f=dict(
340-
cls=widgets.FloatSlider,
341-
value=5.,
342-
),
343-
h=dict(
344-
cls=widgets.Dropdown,
345-
options={'a': 1},
346-
value=1,
347-
),
348-
j=dict(
349-
cls=widgets.Dropdown,
350-
options=('hi', 'there'),
351-
value='hi',
352-
),
353-
)
354-
355-
def test_annotations():
356-
@annotate(n=10, f=widgets.FloatText())
357-
def f(n, f):
358-
pass
359-
360-
c = interactive(f)
361-
check_widgets(c,
362-
n=dict(
363-
cls=widgets.IntSlider,
364-
value=10,
365-
),
366-
f=dict(
367-
cls=widgets.FloatText,
368-
),
369-
)
370-
371-
def test_priority():
372-
@annotate(annotate='annotate', kwarg='annotate')
373-
def f(kwarg='default', annotate='default', default='default'):
374-
pass
375-
376-
c = interactive(f, kwarg='kwarg')
377-
check_widgets(c,
378-
kwarg=dict(
379-
cls=widgets.Text,
380-
value='kwarg',
381-
),
382-
annotate=dict(
383-
cls=widgets.Text,
384-
value='annotate',
385-
),
386-
)
387-
388279
def test_decorator_kwarg(clear_display):
389280
with patch.object(interaction, 'display', record_display):
390281
@interact(a=5)

0 commit comments

Comments
 (0)