bash_kernel icon indicating copy to clipboard operation
bash_kernel copied to clipboard

codemirror_mode shouldn't be in kernel.json

Open akhmerov opened this issue 5 years ago • 0 comments

I'm using bash_kernel via nbconvert, and I noticed the following deprecation warning.

traceback
self = <jupyter_client.kernelspec.KernelSpec object at 0x7f905cddf460>, args = ()
kwargs = {'argv': ['/home/anton/miniconda3/envs/py38/bin/python', '-m', 'bash_kernel', '-f', '{connection_file}'], 'codemirror_mode': 'shell', 'display_name': 'Bash', 'env': {'PS1': '$'}, ...}
super_args = (), super_kwargs = {'codemirror_mode': 'shell'}, key = 'language', value = 'bash', arg_s_list = ["codemirror_mode='shell'"], k = 'codemirror_mode', v = 'shell'
arg_s = "codemirror_mode='shell'"

    def __init__(self, *args, **kwargs):
        # Allow trait values to be set using keyword arguments.
        # We need to use setattr for this to trigger validation and
        # notifications.
        super_args = args
        super_kwargs = {}
        with self.hold_trait_notifications():
            for key, value in kwargs.items():
                if self.has_trait(key):
                    setattr(self, key, value)
                else:
                    # passthrough args that don't set traits to super
                    super_kwargs[key] = value
        try:
            super(HasTraits, self).__init__(*super_args, **super_kwargs)
        except TypeError as e:
            arg_s_list = [ repr(arg) for arg in super_args ]
            for k, v in super_kwargs.items():
                arg_s_list.append("%s=%r" % (k, v))
            arg_s = ', '.join(arg_s_list)
>           warn(
                "Passing unrecognized arguments to super({classname}).__init__({arg_s}).\n"
                "{error}\n"
                "This is deprecated in traitlets 4.2."
                "This error will be raised in a future release of traitlets."
                .format(
                    arg_s=arg_s, classname=self.__class__.__name__,
                    error=e,
                ),
                DeprecationWarning,
                stacklevel=2,
            )
E           DeprecationWarning: Passing unrecognized arguments to super(KernelSpec).__init__(codemirror_mode='shell').
E           object.__init__() takes exactly one argument (the instance to initialize)
E           This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.

../../../miniconda3/envs/py38/lib/python3.8/site-packages/traitlets/traitlets.py:1088: DeprecationWarning

Inspecting jupyter_client, I observed that codemirror_mode is not a trait of KernelSpec (source), and therefore it should probably be removed from this line.

akhmerov avatar Sep 13 '20 20:09 akhmerov