Skip to content

Commit c4acf78

Browse files
[pre-commit.ci] pre-commit autoupdate (#646)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.5.0...v5.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.1.4 → v0.11.4](astral-sh/ruff-pre-commit@v0.1.4...v0.11.4) - [github.com/pre-commit/mirrors-mypy: v1.6.1 → v1.15.0](pre-commit/mirrors-mypy@v1.6.1...v1.15.0) - [github.com/codespell-project/codespell: v2.2.6 → v2.4.1](codespell-project/codespell@v2.2.6...v2.4.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * TST: update expected outputs * MAINT: adding ruff ignores for the test notebooks * MAINT: fix myst lint error * Do not auto-format include generated notebooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Brigitta Sipőcz <[email protected]>
1 parent fc6f43c commit c4acf78

File tree

109 files changed

+760
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+760
-662
lines changed

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ci:
1515
repos:
1616

1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v4.5.0
18+
rev: v5.0.0
1919
hooks:
2020
- id: check-json
2121
- id: check-yaml
@@ -28,14 +28,14 @@ repos:
2828
- id: trailing-whitespace
2929

3030
- repo: https://github.com/astral-sh/ruff-pre-commit
31-
rev: v0.1.4
31+
rev: v0.11.4
3232
hooks:
3333
- id: ruff
3434
args: ["--fix", "--show-fixes"]
3535
- id: ruff-format
3636

3737
- repo: https://github.com/pre-commit/mirrors-mypy
38-
rev: v1.6.1
38+
rev: v1.15.0
3939
hooks:
4040
- id: mypy
4141
args: [--config-file=pyproject.toml]
@@ -51,7 +51,7 @@ repos:
5151
)$
5252
5353
- repo: https://github.com/codespell-project/codespell
54-
rev: v2.2.6
54+
rev: v2.4.1
5555
hooks:
5656
- id: codespell
5757
args: ["-S", "*.ipynb"]

docs/render/orphaned_nb.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
],
3434
"source": [
3535
"from myst_nb import glue\n",
36+
"\n",
3637
"glue(\"var_text\", \"My orphaned variable!\")\n",
37-
"glue(\"var_float\", 1.0/3.0)"
38+
"glue(\"var_float\", 1.0 / 3.0)"
3839
]
3940
}
4041
],

myst_nb/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""A docutils/sphinx parser for Jupyter Notebooks."""
2+
23
__version__ = "1.2.0"
34

45

myst_nb/cli.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""A basic CLI for quickstart of a myst_nb project."""
2+
23
from __future__ import annotations
34

45
import argparse
@@ -81,7 +82,7 @@ def generate_conf_py() -> str:
8182
if field.metadata.get("sphinx_exclude"):
8283
continue
8384
if field.metadata.get("help"):
84-
settings += f'{field.metadata.get("help")}\n'
85+
settings += f"{field.metadata.get('help')}\n"
8586
settings += f"nb_{name} = {value!r}\n\n"
8687
content += "\n" + indent(settings, "# ").rstrip() + "\n"
8788

myst_nb/core/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Configuration for myst-nb."""
2+
23
import dataclasses as dc
34
from enum import Enum
45
from typing import Any, Callable, Dict, Iterable, Literal, Optional, Sequence, Tuple

myst_nb/core/execute/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module for executing notebooks."""
2+
23
from __future__ import annotations
34

45
from pathlib import Path

myst_nb/core/execute/cache.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Execute a notebook from the cache."""
2+
23
from __future__ import annotations
34

45
from contextlib import nullcontext, suppress
@@ -58,7 +59,7 @@ def start_client(self):
5859
# TODO do in try/except, in case of db write errors
5960
NbProjectRecord.remove_tracebacks([stage_record.pk], cache.db)
6061
cwd_context: ContextManager[str] = (
61-
TemporaryDirectory() # type: ignore
62+
TemporaryDirectory()
6263
if self.nb_config.execution_in_temp
6364
else nullcontext(str(self.path.parent))
6465
)

myst_nb/core/execute/direct.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Execute a notebook directly."""
2+
23
from __future__ import annotations
34

45
from contextlib import nullcontext

myst_nb/core/execute/inline.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Execute a notebook inline."""
2+
23
from __future__ import annotations
34

45
import asyncio

myst_nb/core/lexers.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Pygments lexers"""
2+
23
from __future__ import annotations
34

45
import re

myst_nb/core/loggers.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
``logger.warning("message", line=1, subtype="foo")``
1010
1111
"""
12+
1213
import logging
1314
from typing import Union
1415

myst_nb/core/nb_to_tokens.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module for parsing notebooks to Markdown-it tokens."""
2+
23
from __future__ import annotations
34

45
from typing import Any

myst_nb/core/read.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module for reading notebook formats from a string input."""
2+
23
from __future__ import annotations
34

45
import dataclasses as dc

myst_nb/core/render.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Note, this module purposely does not import any Sphinx modules at the top-level,
44
in order for docutils-only use.
55
"""
6+
67
from __future__ import annotations
78

89
from binascii import a2b_base64

myst_nb/core/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Shared utilities."""
2+
23
from __future__ import annotations
34

45
import re

myst_nb/core/variables.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Utilities for rendering code output variables."""
2+
23
from __future__ import annotations
34

45
from ast import literal_eval

myst_nb/docutils_.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The docutils parser implementation for myst-nb."""
2+
23
from __future__ import annotations
34

45
from dataclasses import dataclass, field

myst_nb/ext/eval/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Roles/directives for evaluating variables in the notebook."""
2+
23
from __future__ import annotations
34

45
from functools import partial
@@ -161,9 +162,9 @@ def run(self):
161162
render: dict[str, Any] = {}
162163
for key in ("alt", "height", "width", "scale", "class"):
163164
if key in self.options:
164-
render.setdefault("image", {})[
165-
key.replace("classes", "class")
166-
] = self.options[key]
165+
render.setdefault("image", {})[key.replace("classes", "class")] = (
166+
self.options[key]
167+
)
167168

168169
mime_nodes = render_variable_outputs(
169170
data, self.document, self.line, self.source, render=render

myst_nb/ext/execution_tables.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
which is then replaced by a table of statistics in a post-transformation
55
(once all the documents have been executed and these statistics are available).
66
"""
7+
78
from __future__ import annotations
89

910
from datetime import datetime

myst_nb/ext/glue/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Functionality for storing special data in notebook code cells,
22
which can then be inserted into the document body.
33
"""
4+
45
from __future__ import annotations
56

67
from typing import TYPE_CHECKING, Any

myst_nb/ext/glue/crossref.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Note, we restrict this to a only a subset of mime-types and data -> nodes transforms,
44
since adding these nodes in a post-transform will not apply any transforms to them.
55
"""
6+
67
from __future__ import annotations
78

89
from functools import lru_cache

myst_nb/ext/glue/directives.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
We intentionally do no import sphinx in this module,
44
in order to allow docutils-only use without sphinx installed.
55
"""
6+
67
from typing import TYPE_CHECKING, Any, Dict, List
78

89
from docutils import nodes
@@ -151,9 +152,9 @@ def run(self):
151152
render: Dict[str, Any] = {}
152153
for key in ("alt", "height", "width", "scale", "class"):
153154
if key in self.options:
154-
render.setdefault("image", {})[
155-
key.replace("classes", "class")
156-
] = self.options[key]
155+
render.setdefault("image", {})[key.replace("classes", "class")] = (
156+
self.options[key]
157+
)
157158
paste_nodes = render_variable_outputs(
158159
[data], self.document, self.line, self.source, render=render
159160
)

myst_nb/ext/glue/domain.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This is required for any directive/role names using `:`.
44
"""
5+
56
from sphinx.domains import Domain
67

78
from .directives import (

myst_nb/ext/glue/roles.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
We intentionally do no import sphinx in this module,
44
in order to allow docutils-only use without sphinx installed.
55
"""
6+
67
from __future__ import annotations
78

89
from docutils import nodes

myst_nb/ext/glue/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
We intentionally do no import sphinx in this module,
44
in order to allow docutils-only use without sphinx installed.
55
"""
6+
67
from __future__ import annotations
78

89
from functools import partial

myst_nb/ext/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
We intentionally do no import sphinx in this module,
44
in order to allow docutils-only use without sphinx installed.
55
"""
6+
67
from __future__ import annotations
78

89
from typing import Any

myst_nb/sphinx_.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The sphinx parser implementation for myst-nb."""
2+
23
from __future__ import annotations
34

45
from collections import defaultdict

myst_nb/sphinx_ext.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Setup for the myst-nb sphinx extension."""
2+
23
from __future__ import annotations
34

45
import contextlib

myst_nb/warnings_.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Central handling of warnings for the myst-nb extension."""
2+
23
from __future__ import annotations
34

45
from enum import Enum

pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,16 @@ ignore = [
148148
"E203", # Whitespace before punctuation
149149
]
150150

151+
[tool.ruff.lint.extend-per-file-ignores]
152+
"tests/*/*ipynb" = ["E402"] # module-import-not-at-top-of-file
153+
151154
[tool.ruff.lint.isort]
152155
force-sort-within-sections = true
153156

157+
[tool.ruff.format]
158+
# These are reference outputs and reformatting them makes a mess
159+
exclude = ["tests/test_codecell_file/*ipynb"]
160+
154161
[tool.pytest.ini_options]
155162
filterwarnings = [
156163
'error',

tests/notebooks/basic_failing.ipynb

+41-41
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
{
2-
"cells": [
3-
{
4-
"cell_type": "markdown",
5-
"metadata": {},
6-
"source": [
7-
"# a title\n",
8-
"\n",
9-
"some text\n"
10-
]
11-
},
12-
{
13-
"cell_type": "code",
14-
"execution_count": null,
15-
"metadata": {},
16-
"source": [
17-
"raise Exception('oopsie!')"
18-
],
19-
"outputs": []
20-
}
21-
],
22-
"metadata": {
23-
"test_name": "notebook1",
24-
"kernelspec": {
25-
"display_name": "Python 3",
26-
"language": "python",
27-
"name": "python3"
28-
},
29-
"language_info": {
30-
"codemirror_mode": {
31-
"name": "ipython",
32-
"version": 3
33-
},
34-
"file_extension": ".py",
35-
"mimetype": "text/x-python",
36-
"name": "python",
37-
"nbconvert_exporter": "python",
38-
"pygments_lexer": "ipython3",
39-
"version": "3.6.1"
40-
}
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# a title\n",
8+
"\n",
9+
"some text\n"
10+
]
4111
},
42-
"nbformat": 4,
43-
"nbformat_minor": 2
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"raise Exception(\"oopsie!\")"
19+
]
20+
}
21+
],
22+
"metadata": {
23+
"kernelspec": {
24+
"display_name": "Python 3",
25+
"language": "python",
26+
"name": "python3"
27+
},
28+
"language_info": {
29+
"codemirror_mode": {
30+
"name": "ipython",
31+
"version": 3
32+
},
33+
"file_extension": ".py",
34+
"mimetype": "text/x-python",
35+
"name": "python",
36+
"nbconvert_exporter": "python",
37+
"pygments_lexer": "ipython3",
38+
"version": "3.6.1"
39+
},
40+
"test_name": "notebook1"
41+
},
42+
"nbformat": 4,
43+
"nbformat_minor": 2
4444
}

0 commit comments

Comments
 (0)