From b6378a8ba1331aece202ce66920d0ab745eb185d 2012-06-04 23:52:15 From: MinRK Date: 2012-06-04 23:52:15 Subject: [PATCH] adjust MagicManager.register to handle Configurable magics Configurables don't allow positional args to init, and HasTraits classes don't identify as `type`. --- diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 4f39a53..dff8719 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -30,7 +30,7 @@ from IPython.external.decorator import decorator from IPython.utils.ipstruct import Struct from IPython.utils.process import arg_split from IPython.utils.text import dedent -from IPython.utils.traitlets import Bool, Dict, Instance +from IPython.utils.traitlets import Bool, Dict, Instance, MetaHasTraits from IPython.utils.warn import error, warn #----------------------------------------------------------------------------- @@ -355,10 +355,10 @@ class MagicsManager(Configurable): for m in magic_objects: if not m.registered: raise ValueError("Class of magics %r was constructed without " - "the @register_macics class decorator") - if type(m) is type: + "the @register_magics class decorator") + if type(m) in (type, MetaHasTraits): # If we're given an uninstantiated class - m = m(self.shell) + m = m(shell=self.shell) # Now that we have an instance, we can register it and update the # table of callables