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 from traitlets #1074

Open
yuzie007 opened this issue Sep 5, 2023 · 1 comment
Open

DeprecationWarning from traitlets #1074

yuzie007 opened this issue Sep 5, 2023 · 1 comment

Comments

@yuzie007
Copy link

yuzie007 commented Sep 5, 2023

nglview: 3.0.7
ipywidgets: 8.1.0

First of all, thank you very much @hainm for the development of nglview!

If we use nglview with turning Warning into Exception as

python -W "error" test0.py

where test0.py is

from ase.build import bulk
from nglview.show import show_ase

atoms = bulk("Au")
show_ase(atoms, default=False)

this gives the following error;

Traceback (most recent call last):
  File "/Users/ikeda/miniconda3/envs/myenv/lib/python3.10/site-packages/traitlets/traitlets.py", line 1240, in __init__
    super().__init__(*super_args, **super_kwargs)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ikeda/Documents/projects/nglview/test0.py", line 5, in <module>
    show_ase(atoms, default=False)
  File "/Users/ikeda/miniconda3/envs/myenv/lib/python3.10/site-packages/nglview/show.py", line 85, in show_ase
    return NGLWidget(structure, **kwargs)
  File "/Users/ikeda/miniconda3/envs/myenv/lib/python3.10/site-packages/nglview/widget.py", line 193, in __init__
    super().__init__(**kwargs)
  File "/Users/ikeda/miniconda3/envs/myenv/lib/python3.10/site-packages/ipywidgets/widgets/widget.py", line 503, in __init__
    super().__init__(**kwargs)
  File "/Users/ikeda/miniconda3/envs/myenv/lib/python3.10/site-packages/traitlets/traitlets.py", line 1246, in __init__
    warn(
DeprecationWarning: Passing unrecognized arguments to super(NGLWidget).__init__(default=False).
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.

This is probably not specific for ase but in general for (at least some) show_xxx commands in nglview; the following shows also a similar error

import nglview
nglview.show_pdbid("3pqr", default=False)

I found this issue when I try to solve an issue reported in ase (https://gitlab.com/ase/ase/-/issues/1313). That issue itself is not due to nglview, but when I try to add a test for nglview to solve the issue, the problem I described above emerged. This is because in ase a DeprecationWarning is turned into Exception for safe testing. From the ase side, it would be ideal if this DeprecationWarning issue is solved on the nglview side. It may also make sense, because, as written in the error message above, this issue will raise an error from traitlets in future.

@hainm
Copy link
Collaborator

hainm commented Sep 5, 2023

noted. Thanks @yuzie007.

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

2 participants