Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: ShellWidget._syntax_style_changed is deprecated in traitlets 4.1: use @observe and @unobserve instead #14534

Closed
juliangilbey opened this issue Jan 4, 2021 · 7 comments

Comments

@juliangilbey
Copy link
Contributor

I received the following warning when running the test suite:

spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py::test_banners
  <<<PACKAGEDIR>>>/spyder/plugins/ipythonconsole/widgets/shell.py:789: DeprecationWarning: ShellWidget._syntax_style_changed is deprecated in traitlets 4.1: use @observe and @unobserve instead.
    def _syntax_style_changed(self):

@steff456
Copy link
Member

steff456 commented Jan 5, 2021

Hi @juliangilbey,

Did you installed all the dependencies for the test suite?

@juliangilbey
Copy link
Contributor Author

Yes I have, at least as far as I know; and this does not appear to be a dependency warning or error. I have traitlets 5.0.5 installed.

I don't know enough about traitlets or what magic it does to properly diagnose this issue. But spyder/plugins/ipythonconsole/plugin.py imports from traitlets, which presumably has an impact on lots of things. The particular code in traitlets.py that raises this warning is in the function _notify_observers and reads:

        # Now static ones
        magic_name = '_%s_changed' % name
        if event.type == "change" and hasattr(self, magic_name):
            class_value = getattr(self.__class__, magic_name)
            if not isinstance(class_value, ObserveHandler):
                _deprecated_method(class_value, self.__class__, magic_name,
                    "use @observe and @unobserve instead.")

So it seems that the name of this function, _syntax_style_changed is triggering this traitlets warning: if the name of the function is designed to invoke a traitlets behaviour, then it's not been correctly configured or something like that, and if it's not, then the name of the function should be changed.

But I may be talking nonsense.

@steff456
Copy link
Member

steff456 commented Jan 8, 2021

In my environment I have trailets version 5.0.5, can you update that dependency to see if this fixes the warning?

@juliangilbey
Copy link
Contributor Author

I too have traitlets version 5.0.5.

@juliangilbey
Copy link
Contributor Author

FYI: I'm still getting this warning when running the tests in spyder 5.2.0:

spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py::test_conda_env_activation
  /home/jdg/debian/spyder-packages/spyder/build-area/spyder-5.2.0+dfsg1/spyder/plugins/ipythonconsole/widgets/shell.py:931: DeprecationWarning: ShellWidget._syntax_style_changed is deprecated in traitlets 4.1: use @observe and @unobserve instead.
    def _syntax_style_changed(self):

@dalthviz
Copy link
Member

Maybe the reimplementation over the Spyder side of _syntax_style_changed (originally defined at QtConsole: https://github.com/jupyter/qtconsole/blob/fa1a7f898e7d402ac9bb64a652db5dc509e1f649/qtconsole/jupyter_widget.py#L594-L595) also needs to be decorated with @observe('syntax_style') (and checking seems like over the Spyder side the kwarg is missing). Could you check if that helps @juliangilbey ? Thanks!

@juliangilbey
Copy link
Contributor Author

Yes, that fixed it - well done! I'll make a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants