From 9bd3a1d434d71a9a0721b510f0bb8e6a37a401af 2014-02-07 01:06:07 From: MinRK Date: 2014-02-07 01:06:07 Subject: [PATCH] move @annotate to py3compat --- diff --git a/IPython/html/widgets/__init__.py b/IPython/html/widgets/__init__.py index 8ffbf22..19654b7 100644 --- a/IPython/html/widgets/__init__.py +++ b/IPython/html/widgets/__init__.py @@ -9,4 +9,4 @@ from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, In from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget from .widget_selectioncontainer import TabWidget, AccordionWidget from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget -from .interaction import interact, interactive, annotate, const +from .interaction import interact, interactive, const diff --git a/IPython/html/widgets/interaction.py b/IPython/html/widgets/interaction.py index 65a07a6..b11fff0 100644 --- a/IPython/html/widgets/interaction.py +++ b/IPython/html/widgets/interaction.py @@ -246,17 +246,3 @@ class const(HasTraits): description = Unicode('', help="Any Python object") def __init__(self, value, **kwargs): super(const, self).__init__(value=value, **kwargs) - -def annotate(**kwargs): - """Python 3 compatible function annotation for Python 2.""" - if not kwargs: - raise ValueError('annotations must be provided as keyword arguments') - def dec(f): - if hasattr(f, '__annotations__'): - for k, v in kwargs.items(): - f.__annotations__[k] = v - else: - f.__annotations__ = kwargs - return f - return dec - diff --git a/IPython/utils/py3compat.py b/IPython/utils/py3compat.py index 09d0a82..161c54e 100644 --- a/IPython/utils/py3compat.py +++ b/IPython/utils/py3compat.py @@ -223,6 +223,21 @@ else: filename = fname builtin_mod.execfile(filename, *where) + +def annotate(**kwargs): + """Python 3 compatible function annotation for Python 2.""" + if not kwargs: + raise ValueError('annotations must be provided as keyword arguments') + def dec(f): + if hasattr(f, '__annotations__'): + for k, v in kwargs.items(): + f.__annotations__[k] = v + else: + f.__annotations__ = kwargs + return f + return dec + + # Parts below taken from six: # Copyright (c) 2010-2013 Benjamin Peterson #