ipykernel
ipykernel copied to clipboard
ZMQInteractiveShell.data_pub_class and datapub deprecation
I definitely don't understand understand everything that's going on here, but in hunting down a deprecation error in our tests, I noticed that the following line seems to be causing a DeprecationWarning related to ipykernel.datapub being deprecated:
https://github.com/ipython/ipykernel/blob/ef701eaac9adbc26eea6c2e0aa4452c838a27c81/ipykernel/zmqshell.py#L445
If I switch that line to
class ZMQInteractiveShell(InteractiveShell):
...
data_pub_class = Type('ipyparallel.engine.datapub.ZMQDataPublisher')
then the deprecation warning goes away. of course, ipyparallel is not a dependency of ipykernel, so i guess that would break unless the user had it in their environment (or it was added as a dependency). What is the recommended "future-proof" approach here?
thanks!
I would also be interested to know how to handle this case since it prevents me from running tests with warning as errors.
fwiw @MatthieuDartiailh ... that's what I was after as well, and I get around it by special casing ipykernel as follows:
[tool.pytest.ini_options]
filterwarnings = [
"error:::", # turn warnings into errors
"ignore::DeprecationWarning:ipykernel", # or be more granular if you'd like
]
Thanks for the tip @tlambert03
Still avoiding the warning altogether would be nice.
I also observe this warning when running pytest. I couldn't identify the component/line of code that issues this warning. Interestingly, the warning disappears if I run pytest -W error (the same holds true if I add "error:::" to the pytest ini or the pyproject.toml file, as @tlambert03 suggested). Nothing changed when upgrading to the most recent version of pytest (pytest 6.2.4, python3.9).
In conclusion, I don't think this is a problem that should be posted here. I think this requires a fix in another dependency of pytest or pytest itself.
Meanwhile, another workaround: The deprecation warning has been added in ipykernel 5.4. Downgrading to ipykernel 5.3.4 removes this warning as well.