ipykernel icon indicating copy to clipboard operation
ipykernel copied to clipboard

ZMQInteractiveShell.data_pub_class and datapub deprecation

Open tlambert03 opened this issue 5 years ago • 4 comments

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!

tlambert03 avatar Dec 22 '19 23:12 tlambert03

I would also be interested to know how to handle this case since it prevents me from running tests with warning as errors.

MatthieuDartiailh avatar Jun 19 '21 12:06 MatthieuDartiailh

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
]

tlambert03 avatar Jun 19 '21 12:06 tlambert03

Thanks for the tip @tlambert03

Still avoiding the warning altogether would be nice.

MatthieuDartiailh avatar Jun 19 '21 12:06 MatthieuDartiailh

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.

normanius avatar Jun 24 '21 22:06 normanius