Skip to content

[pre-commit.ci] pre-commit autoupdate #68

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-json
- id: check-yaml
Expand All @@ -14,7 +14,7 @@ repos:
exclude: ^tests/.*\.txt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.11.11
hooks:
- id: ruff
args: [--fix]
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""A pytest plugin for testing Jupyter Notebooks."""

__version__ = "0.10.0"
1 change: 1 addition & 0 deletions pytest_notebook/diffing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Diffing of notebooks."""

import copy
import operator
import re
Expand Down
5 changes: 2 additions & 3 deletions pytest_notebook/example_nbs/coverage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
}
],
"source": [
"\n",
"from pytest_notebook import __version__\n",
"from pytest_notebook.notebook import create_notebook\n",
"print(__version__)\n"
"\n",
"print(__version__)"
]
}
],
Expand Down
8 changes: 3 additions & 5 deletions pytest_notebook/example_nbs/example1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from IPython import display"
]
"source": []
},
{
"cell_type": "code",
Expand All @@ -31,8 +29,8 @@
}
],
"source": [
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
}
],
Expand Down
8 changes: 3 additions & 5 deletions pytest_notebook/example_nbs/example1_pass.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from IPython import display"
]
"source": []
},
{
"cell_type": "code",
Expand All @@ -31,8 +29,8 @@
}
],
"source": [
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
}
],
Expand Down
16 changes: 10 additions & 6 deletions pytest_notebook/example_nbs/example2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
}
],
"source": [
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
},
{
Expand Down Expand Up @@ -118,7 +118,7 @@
],
"source": [
"# code cell + png\n",
"display.Image(filename='128x128.png', width=200, unconfined=True)"
"display.Image(filename=\"128x128.png\", width=200, unconfined=True)"
]
},
{
Expand All @@ -145,7 +145,7 @@
],
"source": [
"# code cell + jpg\n",
"display.Image(filename='128x128.jpg', width=200, unconfined=True)"
"display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)"
]
},
{
Expand Down Expand Up @@ -178,9 +178,13 @@
}
],
"source": [
"print('before exception')\n",
"print(\"before exception\")\n",
"\n",
"\n",
"def func(b):\n",
" raise ValueError('there was an error')\n",
" raise ValueError(\"there was an error\")\n",
"\n",
"\n",
"for i in range(10):\n",
" func(i)"
]
Expand Down
6 changes: 3 additions & 3 deletions pytest_notebook/execution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Execution of notebooks."""

from contextlib import nullcontext
import copy
import json
Expand Down Expand Up @@ -177,8 +178,7 @@ class CoverageError(Exception):
def from_exec_reply(cls, phase, reply):
"""Instantiate from an execution reply."""
return cls(
f"An error occurred while executing coverage {phase}:\n"
f"{reply['content']}"
f"An error occurred while executing coverage {phase}:\n{reply['content']}"
)

@classmethod
Expand All @@ -188,7 +188,7 @@ def from_cell_output(cls, phase, output):
return cls(
f"An error occurred while executing coverage {phase}:\n"
f"{traceback}\n"
f"{output.get('ename', '<Error>')}: { output.get('evalue', '')}"
f"{output.get('ename', '<Error>')}: {output.get('evalue', '')}"
)


Expand Down
3 changes: 2 additions & 1 deletion pytest_notebook/ipy_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
then ``%pytest`` and ``%%pytest`` can be accessed.

"""

# TODO post solution to stackoverflow:
# https://stackoverflow.com/questions/41304311/running-pytest-test-functions-inside-a-jupyter-notebook
import os
Expand All @@ -20,7 +21,7 @@


def parse_cell_content(
cell: Union[str, None]
cell: Union[str, None],
) -> Tuple[List[str], List[str], List[str]]:
"""Parse the cell contents.

Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/nb_regression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Jupyter Notebook Regression Test Class."""

import copy
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/notebook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for working with notebook."""

import copy
from functools import lru_cache

Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- https://docs.pytest.org/en/latest/_modules/_pytest/hookspec.html

"""

import os
import shlex

Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/post_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All functions should take (notebook, resources) as input,
and output a (new notebook, resources).
"""

import copy
import functools
import logging
Expand Down
1 change: 1 addition & 0 deletions pytest_notebook/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions."""

import os
import textwrap
import warnings
Expand Down
1 change: 1 addition & 0 deletions tests/raw_files/coverage_test/call_package.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"outputs": [],
"source": [
"import package\n",
"\n",
"package.func()"
]
}
Expand Down
49 changes: 32 additions & 17 deletions tests/raw_files/different_outputs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"source": [
"# code cell, no output\n",
"import sys\n",
"\n",
"from IPython import display"
]
},
Expand All @@ -38,7 +39,7 @@
],
"source": [
"# code cell + stdout\n",
"print('hallo')"
"print(\"hallo\")"
]
},
{
Expand All @@ -57,8 +58,8 @@
],
"source": [
"# code cell + stdout + stdout\n",
"print('hallo1')\n",
"print('hallo2')"
"print(\"hallo1\")\n",
"print(\"hallo2\")"
]
},
{
Expand All @@ -76,7 +77,7 @@
],
"source": [
"# code cell + stderr\n",
"print('hallo', file=sys.stderr)"
"print(\"hallo\", file=sys.stderr)"
]
},
{
Expand All @@ -101,8 +102,8 @@
],
"source": [
"# code cell + stderr + stdout\n",
"print('hallo1', file=sys.stderr)\n",
"print('hallo2')"
"print(\"hallo1\", file=sys.stderr)\n",
"print(\"hallo2\")"
]
},
{
Expand All @@ -126,7 +127,7 @@
],
"source": [
"# code cell + latex\n",
"display.Latex('\\\\textit{hallo}')"
"display.Latex(\"\\\\textit{hallo}\")"
]
},
{
Expand Down Expand Up @@ -194,7 +195,17 @@
],
"source": [
"# code cell + json\n",
"display.JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}})"
"display.JSON(\n",
" {\n",
" \"a\": [\n",
" 1,\n",
" 2,\n",
" 3,\n",
" 4,\n",
" ],\n",
" \"b\": {\"inner1\": \"helloworld\", \"inner2\": \"foobar\"},\n",
" }\n",
")"
]
},
{
Expand All @@ -220,7 +231,7 @@
],
"source": [
"# code cell + markdown\n",
"display.Markdown('## Header\\n\\n- bullet')"
"display.Markdown(\"## Header\\n\\n- bullet\")"
]
},
{
Expand Down Expand Up @@ -300,7 +311,7 @@
],
"source": [
"# code cell + png\n",
"display.Image(filename='128x128.png', width=200, unconfined=True)"
"display.Image(filename=\"128x128.png\", width=200, unconfined=True)"
]
},
{
Expand All @@ -327,7 +338,7 @@
],
"source": [
"# code cell + jpg\n",
"display.Image(filename='128x128.jpg', width=200, unconfined=True)"
"display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)"
]
},
{
Expand Down Expand Up @@ -381,10 +392,10 @@
}
],
"source": [
"display.display(display.Image(filename='128x128.png', width=200, unconfined=False))\n",
"print('hallo1', file=sys.stderr)\n",
"print('hallo2')\n",
"display.Image(filename='128x128.jpg', width=200, unconfined=True)"
"display.display(display.Image(filename=\"128x128.png\", width=200, unconfined=False))\n",
"print(\"hallo1\", file=sys.stderr)\n",
"print(\"hallo2\")\n",
"display.Image(filename=\"128x128.jpg\", width=200, unconfined=True)"
]
},
{
Expand Down Expand Up @@ -417,9 +428,13 @@
}
],
"source": [
"print('before exception')\n",
"print(\"before exception\")\n",
"\n",
"\n",
"def func(b):\n",
" raise ValueError('there was an error')\n",
" raise ValueError(\"there was an error\")\n",
"\n",
"\n",
"for i in range(10):\n",
" func(i)"
]
Expand Down
Loading
Loading