From 825da52ce075c179e77202e258e8411bbb8928ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:35:46 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- myst_nb/__init__.py | 1 + myst_nb/cli.py | 1 + myst_nb/core/config.py | 1 + myst_nb/core/execute/base.py | 1 + myst_nb/core/execute/cache.py | 1 + myst_nb/core/execute/direct.py | 1 + myst_nb/core/execute/inline.py | 1 + myst_nb/core/lexers.py | 1 + myst_nb/core/loggers.py | 1 + myst_nb/core/nb_to_tokens.py | 1 + myst_nb/core/read.py | 1 + myst_nb/core/render.py | 1 + myst_nb/core/utils.py | 1 + myst_nb/core/variables.py | 1 + myst_nb/docutils_.py | 1 + myst_nb/ext/eval/__init__.py | 7 ++++--- myst_nb/ext/execution_tables.py | 1 + myst_nb/ext/glue/__init__.py | 1 + myst_nb/ext/glue/crossref.py | 1 + myst_nb/ext/glue/directives.py | 7 ++++--- myst_nb/ext/glue/domain.py | 1 + myst_nb/ext/glue/roles.py | 1 + myst_nb/ext/glue/utils.py | 1 + myst_nb/ext/utils.py | 1 + myst_nb/sphinx_.py | 1 + myst_nb/sphinx_ext.py | 1 + myst_nb/warnings_.py | 1 + tests/test_cli.py | 1 + tests/test_codecell_file.py | 1 + tests/test_docutils.py | 1 + tests/test_eval.py | 1 + tests/test_execute.py | 1 + tests/test_glue.py | 1 + tests/test_parser.py | 1 + tests/test_render_outputs.py | 1 + 35 files changed, 41 insertions(+), 6 deletions(-) diff --git a/myst_nb/__init__.py b/myst_nb/__init__.py index 05bec83f..b0af2c4e 100644 --- a/myst_nb/__init__.py +++ b/myst_nb/__init__.py @@ -1,4 +1,5 @@ """A docutils/sphinx parser for Jupyter Notebooks.""" + __version__ = "1.1.1" diff --git a/myst_nb/cli.py b/myst_nb/cli.py index 58637d03..a96aa260 100644 --- a/myst_nb/cli.py +++ b/myst_nb/cli.py @@ -1,4 +1,5 @@ """A basic CLI for quickstart of a myst_nb project.""" + from __future__ import annotations import argparse diff --git a/myst_nb/core/config.py b/myst_nb/core/config.py index 023cccac..c20ce144 100644 --- a/myst_nb/core/config.py +++ b/myst_nb/core/config.py @@ -1,4 +1,5 @@ """Configuration for myst-nb.""" + import dataclasses as dc from enum import Enum from typing import Any, Callable, Dict, Iterable, Literal, Optional, Sequence, Tuple diff --git a/myst_nb/core/execute/base.py b/myst_nb/core/execute/base.py index befb6d29..21570315 100644 --- a/myst_nb/core/execute/base.py +++ b/myst_nb/core/execute/base.py @@ -1,4 +1,5 @@ """Module for executing notebooks.""" + from __future__ import annotations from pathlib import Path diff --git a/myst_nb/core/execute/cache.py b/myst_nb/core/execute/cache.py index f7a26101..d3966b20 100644 --- a/myst_nb/core/execute/cache.py +++ b/myst_nb/core/execute/cache.py @@ -1,4 +1,5 @@ """Execute a notebook from the cache.""" + from __future__ import annotations from contextlib import nullcontext, suppress diff --git a/myst_nb/core/execute/direct.py b/myst_nb/core/execute/direct.py index a8e3e55f..e82624cb 100644 --- a/myst_nb/core/execute/direct.py +++ b/myst_nb/core/execute/direct.py @@ -1,4 +1,5 @@ """Execute a notebook directly.""" + from __future__ import annotations from contextlib import nullcontext diff --git a/myst_nb/core/execute/inline.py b/myst_nb/core/execute/inline.py index 13d20786..06078d04 100644 --- a/myst_nb/core/execute/inline.py +++ b/myst_nb/core/execute/inline.py @@ -1,4 +1,5 @@ """Execute a notebook inline.""" + from __future__ import annotations import asyncio diff --git a/myst_nb/core/lexers.py b/myst_nb/core/lexers.py index 2d4978b6..d49aa3a5 100644 --- a/myst_nb/core/lexers.py +++ b/myst_nb/core/lexers.py @@ -1,4 +1,5 @@ """Pygments lexers""" + from __future__ import annotations import re diff --git a/myst_nb/core/loggers.py b/myst_nb/core/loggers.py index d898d364..960d5be6 100644 --- a/myst_nb/core/loggers.py +++ b/myst_nb/core/loggers.py @@ -9,6 +9,7 @@ ``logger.warning("message", line=1, subtype="foo")`` """ + import logging from typing import Union diff --git a/myst_nb/core/nb_to_tokens.py b/myst_nb/core/nb_to_tokens.py index c8e48f03..8f4d17cb 100644 --- a/myst_nb/core/nb_to_tokens.py +++ b/myst_nb/core/nb_to_tokens.py @@ -1,4 +1,5 @@ """Module for parsing notebooks to Markdown-it tokens.""" + from __future__ import annotations from typing import Any diff --git a/myst_nb/core/read.py b/myst_nb/core/read.py index 2b3dae4b..51325229 100644 --- a/myst_nb/core/read.py +++ b/myst_nb/core/read.py @@ -1,4 +1,5 @@ """Module for reading notebook formats from a string input.""" + from __future__ import annotations import dataclasses as dc diff --git a/myst_nb/core/render.py b/myst_nb/core/render.py index 14b82816..61347590 100644 --- a/myst_nb/core/render.py +++ b/myst_nb/core/render.py @@ -3,6 +3,7 @@ Note, this module purposely does not import any Sphinx modules at the top-level, in order for docutils-only use. """ + from __future__ import annotations from binascii import a2b_base64 diff --git a/myst_nb/core/utils.py b/myst_nb/core/utils.py index d1165712..12331541 100644 --- a/myst_nb/core/utils.py +++ b/myst_nb/core/utils.py @@ -1,4 +1,5 @@ """Shared utilities.""" + from __future__ import annotations import re diff --git a/myst_nb/core/variables.py b/myst_nb/core/variables.py index 0cfffa5f..13911b1a 100644 --- a/myst_nb/core/variables.py +++ b/myst_nb/core/variables.py @@ -1,4 +1,5 @@ """Utilities for rendering code output variables.""" + from __future__ import annotations from ast import literal_eval diff --git a/myst_nb/docutils_.py b/myst_nb/docutils_.py index e3585584..06f80968 100644 --- a/myst_nb/docutils_.py +++ b/myst_nb/docutils_.py @@ -1,4 +1,5 @@ """The docutils parser implementation for myst-nb.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/myst_nb/ext/eval/__init__.py b/myst_nb/ext/eval/__init__.py index 52c04cd2..03769687 100644 --- a/myst_nb/ext/eval/__init__.py +++ b/myst_nb/ext/eval/__init__.py @@ -1,4 +1,5 @@ """Roles/directives for evaluating variables in the notebook.""" + from __future__ import annotations from functools import partial @@ -161,9 +162,9 @@ def run(self): render: dict[str, Any] = {} for key in ("alt", "height", "width", "scale", "class"): if key in self.options: - render.setdefault("image", {})[ - key.replace("classes", "class") - ] = self.options[key] + render.setdefault("image", {})[key.replace("classes", "class")] = ( + self.options[key] + ) mime_nodes = render_variable_outputs( data, self.document, self.line, self.source, render=render diff --git a/myst_nb/ext/execution_tables.py b/myst_nb/ext/execution_tables.py index 3c7c5204..63b67137 100644 --- a/myst_nb/ext/execution_tables.py +++ b/myst_nb/ext/execution_tables.py @@ -4,6 +4,7 @@ which is then replaced by a table of statistics in a post-transformation (once all the documents have been executed and these statistics are available). """ + from __future__ import annotations from datetime import datetime diff --git a/myst_nb/ext/glue/__init__.py b/myst_nb/ext/glue/__init__.py index 8f35284a..a96f3438 100644 --- a/myst_nb/ext/glue/__init__.py +++ b/myst_nb/ext/glue/__init__.py @@ -1,6 +1,7 @@ """Functionality for storing special data in notebook code cells, which can then be inserted into the document body. """ + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/myst_nb/ext/glue/crossref.py b/myst_nb/ext/glue/crossref.py index f2f0c76c..1cc8c455 100644 --- a/myst_nb/ext/glue/crossref.py +++ b/myst_nb/ext/glue/crossref.py @@ -3,6 +3,7 @@ Note, we restrict this to a only a subset of mime-types and data -> nodes transforms, since adding these nodes in a post-transform will not apply any transforms to them. """ + from __future__ import annotations from functools import lru_cache diff --git a/myst_nb/ext/glue/directives.py b/myst_nb/ext/glue/directives.py index 4d42c15a..faf2ba76 100644 --- a/myst_nb/ext/glue/directives.py +++ b/myst_nb/ext/glue/directives.py @@ -3,6 +3,7 @@ We intentionally do no import sphinx in this module, in order to allow docutils-only use without sphinx installed. """ + from typing import TYPE_CHECKING, Any, Dict, List from docutils import nodes @@ -151,9 +152,9 @@ def run(self): render: Dict[str, Any] = {} for key in ("alt", "height", "width", "scale", "class"): if key in self.options: - render.setdefault("image", {})[ - key.replace("classes", "class") - ] = self.options[key] + render.setdefault("image", {})[key.replace("classes", "class")] = ( + self.options[key] + ) paste_nodes = render_variable_outputs( [data], self.document, self.line, self.source, render=render ) diff --git a/myst_nb/ext/glue/domain.py b/myst_nb/ext/glue/domain.py index e00d5239..c31a015b 100644 --- a/myst_nb/ext/glue/domain.py +++ b/myst_nb/ext/glue/domain.py @@ -2,6 +2,7 @@ This is required for any directive/role names using `:`. """ + from sphinx.domains import Domain from .directives import ( diff --git a/myst_nb/ext/glue/roles.py b/myst_nb/ext/glue/roles.py index ee8a5b20..f0f718eb 100644 --- a/myst_nb/ext/glue/roles.py +++ b/myst_nb/ext/glue/roles.py @@ -3,6 +3,7 @@ We intentionally do no import sphinx in this module, in order to allow docutils-only use without sphinx installed. """ + from __future__ import annotations from docutils import nodes diff --git a/myst_nb/ext/glue/utils.py b/myst_nb/ext/glue/utils.py index a61b373a..777fd2b0 100644 --- a/myst_nb/ext/glue/utils.py +++ b/myst_nb/ext/glue/utils.py @@ -3,6 +3,7 @@ We intentionally do no import sphinx in this module, in order to allow docutils-only use without sphinx installed. """ + from __future__ import annotations from functools import partial diff --git a/myst_nb/ext/utils.py b/myst_nb/ext/utils.py index d0076ed0..ea0bcb94 100644 --- a/myst_nb/ext/utils.py +++ b/myst_nb/ext/utils.py @@ -3,6 +3,7 @@ We intentionally do no import sphinx in this module, in order to allow docutils-only use without sphinx installed. """ + from __future__ import annotations from typing import Any diff --git a/myst_nb/sphinx_.py b/myst_nb/sphinx_.py index 4885d9ff..8c20e29e 100644 --- a/myst_nb/sphinx_.py +++ b/myst_nb/sphinx_.py @@ -1,4 +1,5 @@ """The sphinx parser implementation for myst-nb.""" + from __future__ import annotations from collections import defaultdict diff --git a/myst_nb/sphinx_ext.py b/myst_nb/sphinx_ext.py index 7ad07e37..a77cf194 100644 --- a/myst_nb/sphinx_ext.py +++ b/myst_nb/sphinx_ext.py @@ -1,4 +1,5 @@ """Setup for the myst-nb sphinx extension.""" + from __future__ import annotations import contextlib diff --git a/myst_nb/warnings_.py b/myst_nb/warnings_.py index de8e66ce..1c7e9fae 100644 --- a/myst_nb/warnings_.py +++ b/myst_nb/warnings_.py @@ -1,4 +1,5 @@ """Central handling of warnings for the myst-nb extension.""" + from __future__ import annotations from enum import Enum diff --git a/tests/test_cli.py b/tests/test_cli.py index 2153a650..18e7001a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,4 +1,5 @@ """Test the quickstart CLI""" + import os from pathlib import Path diff --git a/tests/test_codecell_file.py b/tests/test_codecell_file.py index 1af9ce8f..ab447279 100644 --- a/tests/test_codecell_file.py +++ b/tests/test_codecell_file.py @@ -1,4 +1,5 @@ """Test notebooks containing code cells with the `load` option.""" + import pytest from sphinx.util.fileutil import copy_asset_file diff --git a/tests/test_docutils.py b/tests/test_docutils.py index 3f3e3af6..74ffcc85 100644 --- a/tests/test_docutils.py +++ b/tests/test_docutils.py @@ -1,4 +1,5 @@ """Run parsing tests against the docutils parser.""" + from io import StringIO import json from pathlib import Path diff --git a/tests/test_eval.py b/tests/test_eval.py index 3a87eab1..7b2da350 100644 --- a/tests/test_eval.py +++ b/tests/test_eval.py @@ -1,4 +1,5 @@ """Test the `eval` directives and roles.""" + import pytest diff --git a/tests/test_execute.py b/tests/test_execute.py index f39d1df0..b6074c7f 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -1,4 +1,5 @@ """Test sphinx builds which execute notebooks.""" + import os from pathlib import Path diff --git a/tests/test_glue.py b/tests/test_glue.py index 119e0b69..e09e8249 100644 --- a/tests/test_glue.py +++ b/tests/test_glue.py @@ -1,4 +1,5 @@ """Test the `glue` directives and roles.""" + from IPython.core.displaypub import DisplayPublisher from IPython.core.interactiveshell import InteractiveShell import nbformat diff --git a/tests/test_parser.py b/tests/test_parser.py index 37f510b8..0a6f440a 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,4 +1,5 @@ """Test parsing of already executed notebooks.""" + import os from pathlib import Path diff --git a/tests/test_render_outputs.py b/tests/test_render_outputs.py index 1b58e181..8b89e0ac 100644 --- a/tests/test_render_outputs.py +++ b/tests/test_render_outputs.py @@ -1,4 +1,5 @@ """Tests for rendering code cell outputs.""" + import pytest from myst_nb.core.render import EntryPointError, load_renderer