From 2cd687422c15719b17c1264b5e95e12f67b9cb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 5 Dec 2024 08:05:53 -0800 Subject: [PATCH] TST: fail on warnings (#647) * CONF: adding pytest config to fail on deprecationwarnings * DEP: remove deprecated sphinx usage * DEP: workaround deprecation * CONF: adding more deprecation warnings to ignore that are triggered upstream * CI: bump myst-parser dependency to avoid the deprecationwarning that gets triggered with the used version combo * Remove typoed upstream word to make codespell happy * CI: ignore warnings triggered only on windows --- .github/workflows/tests.yml | 2 +- myst_nb/core/read.py | 7 +++++-- pyproject.toml | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 484c7dbf..d004c61c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,7 @@ jobs: - os: ubuntu-latest python-version: "3.11" sphinx: "==7.0.0" - myst-parser: "==2.0.0" + myst-parser: "==3.0.0" # Newest known-compatible dependencies - os: ubuntu-latest python-version: "3.12" diff --git a/myst_nb/core/read.py b/myst_nb/core/read.py index 8fc2bb67..9bf6befb 100644 --- a/myst_nb/core/read.py +++ b/myst_nb/core/read.py @@ -57,8 +57,11 @@ def create_nb_reader( :returns: the notebook reader, and the (potentially modified) MdParserConfig, or None if the input cannot be read as a notebook. """ - # the import is here so this module can be loaded without sphinx - from sphinx.util import import_object + + try: + from sphinx.util._importer import import_object + except ImportError: + from sphinx.util import import_object # get all possible readers readers = nb_config.custom_formats.copy() diff --git a/pyproject.toml b/pyproject.toml index 6a62fa0e..b80ede9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -131,6 +131,7 @@ show_error_codes = true check_untyped_defs = true strict_equality = true no_implicit_optional = true +ignore_missing_imports = true warn_unused_ignores = true [[tool.mypy.overrides]] @@ -149,3 +150,25 @@ ignore = [ [tool.ruff.lint.isort] force-sort-within-sections = true + +[tool.pytest.ini_options] +filterwarnings = [ + 'error', + 'ignore:unclosed database in:ResourceWarning', + # from asyncio triggered by jupyter_client + 'ignore:There is no current event loop:DeprecationWarning', + 'ignore:Parsing dates involving a day of month without a year specified is :DeprecationWarning', + # from jupyter_core + 'ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning', + # nbclient + 'ignore:Parsing dates involving a day of month without a year specified is :DeprecationWarning:nbclient', + # From dateutil in sqlalchemy and jupyter_cache + 'ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning:sqlalchemy', + 'ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning:jupyter_cache', + # Windows issues, some may need to be fixed in MyST-NB, others are upstream + 'ignore:Proactor event loop does not implement add_reader:RuntimeWarning:zmq', +] + +markers = [ + "sphinx_params", +]