From f9a13dbb3b8f1ffefef483bdb4c14f04f7743ff1 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Tue, 31 Dec 2019 12:57:52 -0800 Subject: [PATCH 1/2] Fix more python 3 deprecations --- ipywidgets/widgets/interaction.py | 2 +- ipywidgets/widgets/tests/test_interaction.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ipywidgets/widgets/interaction.py b/ipywidgets/widgets/interaction.py index 3dd7272047..6e3b9fc955 100644 --- a/ipywidgets/widgets/interaction.py +++ b/ipywidgets/widgets/interaction.py @@ -246,7 +246,7 @@ def update(self, *args): except Exception as e: ip = get_ipython() if ip is None: - self.log.warn("Exception in interact callback: %s", e, exc_info=True) + self.log.warning("Exception in interact callback: %s", e, exc_info=True) else: ip.showtraceback() finally: diff --git a/ipywidgets/widgets/tests/test_interaction.py b/ipywidgets/widgets/tests/test_interaction.py index 1ee946744e..c792c5377a 100644 --- a/ipywidgets/widgets/tests/test_interaction.py +++ b/ipywidgets/widgets/tests/test_interaction.py @@ -249,7 +249,8 @@ def test_iterable_tuple(): check_widgets(c, lis=d) def test_mapping(): - from collections import Mapping, OrderedDict + from collections.abc import Mapping + from collections import OrderedDict class TestMapping(Mapping): def __init__(self, values): self.values = values From 372457b8cb1523ecd5120b508e2d9c3a5f43c2e8 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Tue, 31 Dec 2019 13:02:05 -0800 Subject: [PATCH 2/2] Remove deprecated annotation support See #1292 --- ipywidgets/widgets/interaction.py | 4 - ipywidgets/widgets/tests/test_interaction.py | 110 ------------------- 2 files changed, 114 deletions(-) diff --git a/ipywidgets/widgets/interaction.py b/ipywidgets/widgets/interaction.py index 6e3b9fc955..af7662a36b 100644 --- a/ipywidgets/widgets/interaction.py +++ b/ipywidgets/widgets/interaction.py @@ -117,15 +117,11 @@ def _yield_abbreviations_for_parameter(param, kwargs): """Get an abbreviation for a function parameter.""" name = param.name kind = param.kind - ann = param.annotation default = param.default not_found = (name, empty, empty) if kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.KEYWORD_ONLY): if name in kwargs: value = kwargs.pop(name) - elif ann is not empty: - warn("Using function annotations to implicitly specify interactive controls is deprecated. Use an explicit keyword argument for the parameter instead.", DeprecationWarning) - value = ann elif default is not empty: value = default else: diff --git a/ipywidgets/widgets/tests/test_interaction.py b/ipywidgets/widgets/tests/test_interaction.py index c792c5377a..d678e461df 100644 --- a/ipywidgets/widgets/tests/test_interaction.py +++ b/ipywidgets/widgets/tests/test_interaction.py @@ -14,7 +14,6 @@ from traitlets import TraitError from ipywidgets import (interact, interact_manual, interactive, interaction, Output) -from ipython_genutils.py3compat import annotate #----------------------------------------------------------------------------- # Utility stuff @@ -277,115 +276,6 @@ def items(self): ) check_widgets(c, lis=d) - -def test_defaults(): - @annotate(n=10) - def f(n, f=4.5, g=1): - pass - - c = interactive(f) - check_widgets(c, - n=dict( - cls=widgets.IntSlider, - value=10, - ), - f=dict( - cls=widgets.FloatSlider, - value=4.5, - ), - g=dict( - cls=widgets.IntSlider, - value=1, - ), - ) - -def test_default_values(): - @annotate(n=10, f=(0, 10.), g=5, h=OrderedDict([('a',1), ('b',2)]), j=['hi', 'there']) - def f(n, f=4.5, g=1, h=2, j='there'): - pass - - c = interactive(f) - check_widgets(c, - n=dict( - cls=widgets.IntSlider, - value=10, - ), - f=dict( - cls=widgets.FloatSlider, - value=4.5, - ), - g=dict( - cls=widgets.IntSlider, - value=5, - ), - h=dict( - cls=widgets.Dropdown, - options=OrderedDict([('a',1), ('b',2)]), - value=2 - ), - j=dict( - cls=widgets.Dropdown, - options=('hi', 'there'), - value='there' - ), - ) - -def test_default_out_of_bounds(): - @annotate(f=(0, 10.), h={'a': 1}, j=['hi', 'there']) - def f(f='hi', h=5, j='other'): - pass - - c = interactive(f) - check_widgets(c, - f=dict( - cls=widgets.FloatSlider, - value=5., - ), - h=dict( - cls=widgets.Dropdown, - options={'a': 1}, - value=1, - ), - j=dict( - cls=widgets.Dropdown, - options=('hi', 'there'), - value='hi', - ), - ) - -def test_annotations(): - @annotate(n=10, f=widgets.FloatText()) - def f(n, f): - pass - - c = interactive(f) - check_widgets(c, - n=dict( - cls=widgets.IntSlider, - value=10, - ), - f=dict( - cls=widgets.FloatText, - ), - ) - -def test_priority(): - @annotate(annotate='annotate', kwarg='annotate') - def f(kwarg='default', annotate='default', default='default'): - pass - - c = interactive(f, kwarg='kwarg') - check_widgets(c, - kwarg=dict( - cls=widgets.Text, - value='kwarg', - ), - annotate=dict( - cls=widgets.Text, - value='annotate', - ), - ) - def test_decorator_kwarg(clear_display): with patch.object(interaction, 'display', record_display): @interact(a=5)