diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a37851e1..1bdad8dd5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-case-conflict - id: check-ast @@ -21,12 +21,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.28.4 + rev: 0.31.1 hooks: - id: check-github-workflows - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.22 hooks: - id: mdformat additional_dependencies: @@ -39,19 +39,19 @@ repos: types_or: [yaml, html, json] - repo: https://github.com/adamchainz/blacken-docs - rev: "1.16.0" + rev: "1.19.1" hooks: - id: blacken-docs additional_dependencies: [black==23.7.0] - repo: https://github.com/codespell-project/codespell - rev: "v2.3.0" + rev: "v2.4.1" hooks: - id: codespell args: ["-L", "sur,nd,assertin"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.10.0" + rev: "v1.14.1" hooks: - id: mypy files: "^nbconvert" @@ -81,7 +81,7 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.8 + rev: v0.9.4 hooks: - id: ruff types_or: [python, jupyter] @@ -90,7 +90,7 @@ repos: types_or: [python, jupyter] - repo: https://github.com/scientific-python/cookie - rev: "2024.04.23" + rev: "2025.01.22" hooks: - id: sp-repo-review additional_dependencies: ["repo-review[cli]"] diff --git a/CHANGELOG.md b/CHANGELOG.md index bb4c31f6e..0058228e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ ### Maintenance and upkeep improvements -- enhancement dep-chain: directly depend on bleach\[css\], instead of pulling in tinycss2. [#2166](https://github.com/jupyter/nbconvert/pull/2166) ([@xiacunshun](https://github.com/xiacunshun)) +- enhancement dep-chain: directly depend on bleach[css], instead of pulling in tinycss2. [#2166](https://github.com/jupyter/nbconvert/pull/2166) ([@xiacunshun](https://github.com/xiacunshun)) - chore: update pre-commit hooks [#2146](https://github.com/jupyter/nbconvert/pull/2146) ([@pre-commit-ci](https://github.com/pre-commit-ci)) ### Contributors to this release @@ -94,7 +94,7 @@ ### Bugs fixed -- \[HTMLExporter\] Initialize resources before widget filtering [#2118](https://github.com/jupyter/nbconvert/pull/2118) ([@yuvipanda](https://github.com/yuvipanda)) +- [HTMLExporter] Initialize resources before widget filtering [#2118](https://github.com/jupyter/nbconvert/pull/2118) ([@yuvipanda](https://github.com/yuvipanda)) ### Contributors to this release @@ -437,7 +437,7 @@ ### Enhancements made -- \[Accessibility\] some accessibility improvements [#2021](https://github.com/jupyter/nbconvert/pull/2021) ([@brichet](https://github.com/brichet)) +- [Accessibility] some accessibility improvements [#2021](https://github.com/jupyter/nbconvert/pull/2021) ([@brichet](https://github.com/brichet)) - Adopt playwright [#2013](https://github.com/jupyter/nbconvert/pull/2013) ([@brichet](https://github.com/brichet)) - Update to Jupyterlab 4 [#2012](https://github.com/jupyter/nbconvert/pull/2012) ([@brichet](https://github.com/brichet)) @@ -1634,6 +1634,7 @@ raw template {%- endblock in_prompt -%} """ + exporter_attr = AttrExporter() output_attr, _ = exporter_attr.from_notebook_node(nb) assert "raw template" in output_attr diff --git a/README.md b/README.md index 5f2287c47..22af74f7b 100644 --- a/README.md +++ b/README.md @@ -102,8 +102,8 @@ Jupyter uses a shared copyright model. Each contributor maintains copyright over their contributions to Jupyter. But, it is important to note that these contributions are typically only changes to the repositories. Thus, the Jupyter source code, in its entirety is not the copyright of any single person or -institution. Instead, it is the collective copyright of the entire Jupyter -Development Team. If individual contributors want to maintain a record of what +institution. Instead, it is the collective copyright of the entire Jupyter +Development Team. If individual contributors want to maintain a record of what changes/contributions they have specific copyright on, they should indicate their copyright in the commit message of the change, when they commit the change to one of the Jupyter repositories. diff --git a/docs/api_examples/template_path/make_html.py b/docs/api_examples/template_path/make_html.py index ce283bba1..e60292e63 100644 --- a/docs/api_examples/template_path/make_html.py +++ b/docs/api_examples/template_path/make_html.py @@ -20,4 +20,4 @@ (body, resources) = html_exporter.from_notebook_node(the_ipynb) with open(f"{template}.html", "w") as outfile: outfile.write(body) - print(f"\n{'*'*20}\n{template} succeeds\n{'*'*20}\n") + print(f"\n{'*' * 20}\n{template} succeeds\n{'*' * 20}\n") diff --git a/nbconvert/__init__.py b/nbconvert/__init__.py index bd860d30b..9ccd3d584 100644 --- a/nbconvert/__init__.py +++ b/nbconvert/__init__.py @@ -32,18 +32,9 @@ __all__ = [ - "__version__", - "version_info", - "filters", - "postprocessors", - "preprocessors", - "writers", "ASCIIDocExporter", - "ExporterNameError", - "export", - "get_export_names", - "get_exporter", "Exporter", + "ExporterNameError", "FilenameExtension", "HTMLExporter", "LatexExporter", @@ -58,4 +49,13 @@ "SlidesExporter", "TemplateExporter", "WebPDFExporter", + "__version__", + "export", + "filters", + "get_export_names", + "get_exporter", + "postprocessors", + "preprocessors", + "version_info", + "writers", ] diff --git a/nbconvert/exporters/__init__.py b/nbconvert/exporters/__init__.py index c043f8fce..35819a643 100644 --- a/nbconvert/exporters/__init__.py +++ b/nbconvert/exporters/__init__.py @@ -17,12 +17,9 @@ __all__ = [ "ASCIIDocExporter", - "ExporterNameError", - "ExporterDisabledError", - "export", - "get_export_names", - "get_exporter", "Exporter", + "ExporterDisabledError", + "ExporterNameError", "FilenameExtension", "HTMLExporter", "LatexExporter", @@ -32,10 +29,13 @@ "PythonExporter", "QtPDFExporter", "QtPNGExporter", - "ResourcesDict", "RSTExporter", + "ResourcesDict", "ScriptExporter", "SlidesExporter", "TemplateExporter", "WebPDFExporter", + "export", + "get_export_names", + "get_exporter", ] diff --git a/nbconvert/exporters/base.py b/nbconvert/exporters/base.py index b71f10258..cc985d0db 100644 --- a/nbconvert/exporters/base.py +++ b/nbconvert/exporters/base.py @@ -22,11 +22,11 @@ # ----------------------------------------------------------------------------- __all__ = [ - "export", "Exporter", - "get_exporter", - "get_export_names", "ExporterNameError", + "export", + "get_export_names", + "get_exporter", ] diff --git a/nbconvert/exporters/qt_exporter.py b/nbconvert/exporters/qt_exporter.py index 2755a0da8..0fbfa337b 100644 --- a/nbconvert/exporters/qt_exporter.py +++ b/nbconvert/exporters/qt_exporter.py @@ -38,7 +38,7 @@ def _check_launch_reqs(self): def _run_pyqtwebengine(self, html): ext = ".html" temp_file = tempfile.NamedTemporaryFile(suffix=ext, delete=False) - filename = f"{temp_file.name[:-len(ext)]}.{self.format}" + filename = f"{temp_file.name[: -len(ext)]}.{self.format}" with temp_file: temp_file.write(html.encode("utf-8")) try: diff --git a/nbconvert/filters/__init__.py b/nbconvert/filters/__init__.py index 27bedca1e..e5370966c 100644 --- a/nbconvert/filters/__init__.py +++ b/nbconvert/filters/__init__.py @@ -35,38 +35,38 @@ ) __all__ = [ - "indent", - "ansi2html", - "ansi2latex", - "strip_ansi", - "citation2latex", + "ConvertExplicitlyRelativePaths", "DataTypeFilter", "Highlight2HTML", "Highlight2Latex", + "add_anchor", + "add_prompts", + "ansi2html", + "ansi2latex", + "ascii_only", + "citation2latex", + "clean_html", + "comment_lines", + "convert_pandoc", "escape_latex", + "get_lines", + "get_metadata", + "html2text", + "indent", + "ipython2python", + "markdown2asciidoc", "markdown2html", - "markdown2html_pandoc", "markdown2html_mistune", + "markdown2html_pandoc", "markdown2latex", "markdown2rst", - "markdown2asciidoc", - "get_metadata", - "convert_pandoc", - "ConvertExplicitlyRelativePaths", - "wrap_text", - "html2text", - "clean_html", - "add_anchor", - "strip_dollars", - "strip_files_prefix", - "comment_lines", - "get_lines", - "ipython2python", - "posix_path", "path2url", - "add_prompts", - "ascii_only", + "posix_path", "prevent_list_blocks", + "strip_ansi", + "strip_dollars", + "strip_files_prefix", "strip_trailing_newline", "text_base64", + "wrap_text", ] diff --git a/nbconvert/filters/ansi.py b/nbconvert/filters/ansi.py index a9882e10e..12949a1e5 100644 --- a/nbconvert/filters/ansi.py +++ b/nbconvert/filters/ansi.py @@ -7,7 +7,7 @@ import markupsafe -__all__ = ["strip_ansi", "ansi2html", "ansi2latex"] +__all__ = ["ansi2html", "ansi2latex", "strip_ansi"] _ANSI_RE = re.compile("\x1b\\[(.*?)([@-~])") diff --git a/nbconvert/filters/markdown.py b/nbconvert/filters/markdown.py index 1cf270200..b6f801091 100644 --- a/nbconvert/filters/markdown.py +++ b/nbconvert/filters/markdown.py @@ -27,12 +27,12 @@ def markdown2html_mistune(source: str) -> str: from .pandoc import convert_pandoc __all__ = [ + "markdown2asciidoc", "markdown2html", - "markdown2html_pandoc", "markdown2html_mistune", + "markdown2html_pandoc", "markdown2latex", "markdown2rst", - "markdown2asciidoc", ] diff --git a/nbconvert/filters/strings.py b/nbconvert/filters/strings.py index 81a0453ad..32ff133a9 100644 --- a/nbconvert/filters/strings.py +++ b/nbconvert/filters/strings.py @@ -23,22 +23,22 @@ from nbconvert.preprocessors.sanitize import _get_default_css_sanitizer __all__ = [ - "wrap_text", - "html2text", - "clean_html", "add_anchor", - "strip_dollars", - "strip_files_prefix", + "add_prompts", + "ascii_only", + "clean_html", "comment_lines", "get_lines", + "html2text", "ipython2python", - "posix_path", "path2url", - "add_prompts", - "ascii_only", + "posix_path", "prevent_list_blocks", + "strip_dollars", + "strip_files_prefix", "strip_trailing_newline", "text_base64", + "wrap_text", ] diff --git a/nbconvert/preprocessors/__init__.py b/nbconvert/preprocessors/__init__.py index d752edf90..3e29ae171 100644 --- a/nbconvert/preprocessors/__init__.py +++ b/nbconvert/preprocessors/__init__.py @@ -18,18 +18,18 @@ from .tagremove import TagRemovePreprocessor __all__ = [ + "CSSHTMLHeaderPreprocessor", "CellExecutionError", - "Preprocessor", "ClearMetadataPreprocessor", "ClearOutputPreprocessor", "CoalesceStreamsPreprocessor", "ConvertFiguresPreprocessor", - "CSSHTMLHeaderPreprocessor", "ExecutePreprocessor", "ExtractAttachmentsPreprocessor", "ExtractOutputPreprocessor", "HighlightMagicsPreprocessor", "LatexPreprocessor", + "Preprocessor", "RegexRemovePreprocessor", "SVG2PDFPreprocessor", "TagRemovePreprocessor", diff --git a/nbconvert/preprocessors/tagremove.py b/nbconvert/preprocessors/tagremove.py index 12c7d3036..f1daa62de 100644 --- a/nbconvert/preprocessors/tagremove.py +++ b/nbconvert/preprocessors/tagremove.py @@ -37,8 +37,7 @@ class TagRemovePreprocessor(Preprocessor): Unicode(), default_value=[], help=( - "Tags indicating which cells are to be removed," - "matches tags in ``cell.metadata.tags``." + "Tags indicating which cells are to be removed,matches tags in ``cell.metadata.tags``." ), ).tag(config=True) remove_all_outputs_tags: set[str] = Set( # type:ignore[assignment] diff --git a/tests/exporters/test_webpdf.py b/tests/exporters/test_webpdf.py index ef9f8ed77..ad6b7a9aa 100644 --- a/tests/exporters/test_webpdf.py +++ b/tests/exporters/test_webpdf.py @@ -33,7 +33,7 @@ class TestWebPDFExporter(ExportersTestsBase): exporter_class = WebPDFExporter # type:ignore - @pytest.mark.network() + @pytest.mark.network def test_export(self): """ Can a TemplateExporter export something? diff --git a/tests/filters/test_markdown.py b/tests/filters/test_markdown.py index 4b1cdc354..00b6a9f7f 100644 --- a/tests/filters/test_markdown.py +++ b/tests/filters/test_markdown.py @@ -142,14 +142,7 @@ def test_markdown2html_math(self): "$$aa;a-b<0$$", "$$$$", ("$$x\n=\n2$$"), - ( - "$$\n" - "b = \\left[\n" - "P\\left(\\right)\n" - "- (l_1\\leftrightarrow l_2\n)" - "\\right]\n" - "$$" - ), + ("$$\nb = \\left[\nP\\left(\\right)\n- (l_1\\leftrightarrow l_2\n)\\right]\n$$"), ("\\begin{equation*}\nx = 2 *55* 7\n\\end{equation*}"), """$ \\begin{tabular}{ l c r } diff --git a/tests/test_nbconvertapp.py b/tests/test_nbconvertapp.py index f181d9539..53532d02c 100644 --- a/tests/test_nbconvertapp.py +++ b/tests/test_nbconvertapp.py @@ -151,7 +151,7 @@ def test_filename_spaces(self): assert os.path.isfile("notebook with spaces.pdf") @flaky - @pytest.mark.network() + @pytest.mark.network @pytest.mark.skipif(not PLAYWRIGHT_INSTALLED, reason="Playwright not installed") def test_webpdf_with_chromium(self): """ @@ -537,8 +537,7 @@ def fig_exists(path): # check relative path with self.create_temp_cwd(["notebook4_jpeg.ipynb", "containerized_deployments.jpeg"]): self.nbconvert( - "--log-level 0 notebook4_jpeg.ipynb --to rst " - "--NbConvertApp.output_files_dir=output" + "--log-level 0 notebook4_jpeg.ipynb --to rst --NbConvertApp.output_files_dir=output" ) assert fig_exists("output")