From 320d056f17026cbca3115b5f3ce82bde5213afca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:43:05 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- nbconvert/exporters/html.py | 7 +++---- nbconvert/exporters/slides.py | 2 +- nbconvert/filters/ansi.py | 2 +- nbconvert/filters/citation.py | 2 +- nbconvert/filters/markdown_mistune.py | 2 +- tests/base.py | 8 ++++---- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/nbconvert/exporters/html.py b/nbconvert/exporters/html.py index 523ea44dd..d8be7e2a4 100644 --- a/nbconvert/exporters/html.py +++ b/nbconvert/exporters/html.py @@ -266,8 +266,8 @@ def from_notebook_node( # type:ignore[explicit-override, override] markdown_collection = markdown_collection + cell.source + "\n" resources = self._init_resources(resources) - print('type:', resources) - + print("type:", resources) + resources["tableofcontents"] = extract_titles_from_markdown_input(markdown_collection) filter_data_type = WidgetsDataTypeFilter( @@ -356,8 +356,7 @@ def resources_include_url(name): return markupsafe.Markup(src) resources = super()._init_resources(resources) - - + resources["theme"] = self.theme resources["include_css"] = resources_include_css resources["include_lab_theme"] = resources_include_lab_theme diff --git a/nbconvert/exporters/slides.py b/nbconvert/exporters/slides.py index 62a11402b..e571a90c0 100644 --- a/nbconvert/exporters/slides.py +++ b/nbconvert/exporters/slides.py @@ -41,7 +41,7 @@ def preprocess(self, nb, resources=None): in_fragment = False - for index, cell in enumerate(nb.cells[first_slide_ix + 1:], start=(first_slide_ix + 1)): + for index, cell in enumerate(nb.cells[first_slide_ix + 1 :], start=(first_slide_ix + 1)): previous_cell = nb.cells[index - 1] # Slides are
elements in the HTML, subslides (the vertically diff --git a/nbconvert/filters/ansi.py b/nbconvert/filters/ansi.py index ac91fc89f..a9882e10e 100644 --- a/nbconvert/filters/ansi.py +++ b/nbconvert/filters/ansi.py @@ -197,7 +197,7 @@ def _ansi2anything(text, converter): pass # Invalid color specification else: pass # Not a color code - chunk, text = text[: m.start()], text[m.end():] + chunk, text = text[: m.start()], text[m.end() :] else: chunk, text = text, "" diff --git a/nbconvert/filters/citation.py b/nbconvert/filters/citation.py index e078ceed0..0db092a42 100644 --- a/nbconvert/filters/citation.py +++ b/nbconvert/filters/citation.py @@ -42,7 +42,7 @@ def citation2latex(s): outtext = "" startpos = 0 for citation in parser.citelist: - outtext += s[startpos: citation[1]] + outtext += s[startpos : citation[1]] outtext += "\\cite{%s}" % citation[0] startpos = citation[2] if len(citation) == 3 else -1 outtext += s[startpos:] if startpos != -1 else "" diff --git a/nbconvert/filters/markdown_mistune.py b/nbconvert/filters/markdown_mistune.py index 0c698fc27..d9ecf0c5e 100644 --- a/nbconvert/filters/markdown_mistune.py +++ b/nbconvert/filters/markdown_mistune.py @@ -385,7 +385,7 @@ def _embed_image_or_attachment(self, src: str) -> str: attachment_prefix = "attachment:" if src.startswith(attachment_prefix): - name = src[len(attachment_prefix):] + name = src[len(attachment_prefix) :] if name not in self.attachments: msg = f"missing attachment: {name}" diff --git a/tests/base.py b/tests/base.py index d854900a8..ff2bec3d5 100644 --- a/tests/base.py +++ b/tests/base.py @@ -176,15 +176,15 @@ def assert_big_text_equal(a, b, chunk_size=80): to give better info than vanilla assertEqual for large text blobs. """ for i in range(0, len(a), chunk_size): - chunk_a = a[i: i + chunk_size] - chunk_b = b[i: i + chunk_size] + chunk_a = a[i : i + chunk_size] + chunk_b = b[i : i + chunk_size] assert chunk_a == chunk_b, "[offset: %i]\n%r != \n%r" % (i, chunk_a, chunk_b) if len(a) > len(b): raise AssertionError( - "Length doesn't match (%i > %i). Extra text:\n%r" % (len(a), len(b), a[len(b):]) + "Length doesn't match (%i > %i). Extra text:\n%r" % (len(a), len(b), a[len(b) :]) ) if len(a) < len(b): raise AssertionError( - "Length doesn't match (%i < %i). Extra text:\n%r" % (len(a), len(b), a[len(b):]) + "Length doesn't match (%i < %i). Extra text:\n%r" % (len(a), len(b), a[len(b) :]) )