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 on a fresh install on CI #398

Open
mgeier opened this issue Apr 6, 2024 · 3 comments
Open

DeprecationWarning on a fresh install on CI #398

mgeier opened this issue Apr 6, 2024 · 3 comments

Comments

@mgeier
Copy link

mgeier commented Apr 6, 2024

When invoking nbconvert on CI with warnings turned into errors (e.g. https://github.com/mgeier/nbsphinx/actions/runs/8581467203/job/23518524054), I'm getting this warning/error:

Exception occurred:
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jupyter_core/utils/__init__.py", line 90, in deprecation
    warnings.warn(message, DeprecationWarning, stacklevel=stacklevel + 1)
DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
given by the platformdirs library.  To remove this warning and
see the appropriate new directories, set the environment variable
`JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
The use of platformdirs will be the default in `jupyter_core` v6

I would expect the module to work out-of-the-box if freshly installed.
Am I supposed to run jupyter --paths each time in CI?

@liquidcarbon
Copy link

I got this stuff showing up in pytests, in a package I'm building from scratch.
Oddly, it first appeared on adding from loguru import logger.

Here is a decent workaround, allowing the test files to import stuff from main package without the nuisance warning.

# tests/__init__.py

import os

# disable DeprecationWarning https://github.com/jupyter/jupyter_core/issues/398
os.environ["JUPYTER_PLATFORM_DIRS"] = "1"

@sglbl
Copy link

sglbl commented Oct 3, 2024

If you got this error while using pytest you can also create a pytest.ini file where conftest or tester script is located:
Content:

[pytest]
filterwarnings =  
    ignore::DeprecationWarning
    ignore::FutureWarning

@Pitrified
Copy link

sglbl got me on the right path but I prefer to avoid a blanket filter on all DeprecationWarnings, so I put this in my pyproject.toml

[tool.pytest.ini_options]
filterwarnings = [
    "ignore:.*Jupyter is migrating.*:DeprecationWarning",
]

A very similar syntax should work for pytest.ini

Cheers!

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

No branches or pull requests

4 participants