From ca1e94e9fb840b19c34e8fd5a7d14803447fbffa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 07:27:06 -0500 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#2027) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester --- .pre-commit-config.yaml | 6 +++--- nbconvert/exporters/base.py | 3 ++- nbconvert/exporters/script.py | 2 +- nbconvert/filters/highlight.py | 2 +- nbconvert/filters/markdown_mistune.py | 2 +- nbconvert/nbconvertapp.py | 16 ++++++---------- nbconvert/preprocessors/sanitize.py | 2 +- pyproject.toml | 2 +- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e21a4a8f0..9d044bb68 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.23.2 + rev: 0.23.3 hooks: - id: check-github-workflows @@ -31,12 +31,12 @@ repos: [mdformat-gfm, mdformat-frontmatter, mdformat-footnote] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.276 + rev: v0.0.281 hooks: - id: ruff args: ["--fix"] diff --git a/nbconvert/exporters/base.py b/nbconvert/exporters/base.py index f0c2efad5..a0a08cd50 100644 --- a/nbconvert/exporters/base.py +++ b/nbconvert/exporters/base.py @@ -106,7 +106,8 @@ def get_exporter(name, config=get_config()): # noqa try: exporters = entry_points(group="nbconvert.exporters") - exporter = [e for e in exporters if e.name == name or e.name == name.lower()][0].load() + items = [e for e in exporters if e.name == name or e.name == name.lower()] + exporter = items[0].load() if getattr(exporter(config=config), "enabled", True): return exporter else: diff --git a/nbconvert/exporters/script.py b/nbconvert/exporters/script.py index 144a197a9..d4552fcdd 100644 --- a/nbconvert/exporters/script.py +++ b/nbconvert/exporters/script.py @@ -39,7 +39,7 @@ def _get_language_exporter(self, lang_name): if lang_name not in self._lang_exporters: try: exporters = entry_points(group="nbconvert.exporters.script") - exporter = [e for e in exporters if e.name == lang_name][0].load() + exporter = [e for e in exporters if e.name == lang_name][0].load() # noqa except (KeyError, IndexError): self._lang_exporters[lang_name] = None else: diff --git a/nbconvert/filters/highlight.py b/nbconvert/filters/highlight.py index c8398ab8e..2a5fc7798 100644 --- a/nbconvert/filters/highlight.py +++ b/nbconvert/filters/highlight.py @@ -132,7 +132,7 @@ def __call__(self, source, language=None, metadata=None, strip_verbatim=False): source, LatexFormatter(**self.extra_formatter_options), language, metadata ) if strip_verbatim: - latex = latex.replace(r"\begin{Verbatim}[commandchars=\\\{\}]" + "\n", "") # noqa + latex = latex.replace(r"\begin{Verbatim}[commandchars=\\\{\}]" + "\n", "") return latex.replace("\n\\end{Verbatim}\n", "") else: return latex diff --git a/nbconvert/filters/markdown_mistune.py b/nbconvert/filters/markdown_mistune.py index 55a376781..91ae1c1e9 100644 --- a/nbconvert/filters/markdown_mistune.py +++ b/nbconvert/filters/markdown_mistune.py @@ -398,7 +398,7 @@ def _embed_image_or_attachment(self, src: str) -> str: if mime_type in attachment: return f"data:{mime_type};base64,{attachment[mime_type]}" # otherwise we choose the first mimetype we can find - default_mime_type = tuple(attachment.keys())[0] + default_mime_type = next(iter(attachment.keys())) return f"data:{default_mime_type};base64,{attachment[default_mime_type]}" elif self.embed_images: diff --git a/nbconvert/nbconvertapp.py b/nbconvert/nbconvertapp.py index d9985d90b..01e608329 100755 --- a/nbconvert/nbconvertapp.py +++ b/nbconvert/nbconvertapp.py @@ -237,12 +237,12 @@ def _classes_default(self): ).tag(config=True) examples = Unicode( - """ + f""" The simplest way to use nbconvert is > jupyter nbconvert mynotebook.ipynb --to html - Options include {formats}. + Options include {get_export_names()}. > jupyter nbconvert --to latex mynotebook.ipynb @@ -275,9 +275,7 @@ def _classes_default(self): c.NbConvertApp.notebooks = ["my_notebook.ipynb"] > jupyter nbconvert --config mycfg.py - """.format( - formats=get_export_names() - ) + """ ) # Writer specific variables @@ -331,12 +329,10 @@ def _postprocessor_class_changed(self, change): export_format = Unicode( allow_none=False, - help="""The export format to be used, either one of the built-in formats - {formats} + help=f"""The export format to be used, either one of the built-in formats + {get_export_names()} or a dotted object name that represents the import path for an - ``Exporter`` class""".format( - formats=get_export_names() - ), + ``Exporter`` class""", ).tag(config=True) notebooks = List( diff --git a/nbconvert/preprocessors/sanitize.py b/nbconvert/preprocessors/sanitize.py index c0cc7e004..5cdfc5ebe 100644 --- a/nbconvert/preprocessors/sanitize.py +++ b/nbconvert/preprocessors/sanitize.py @@ -111,7 +111,7 @@ def preprocess_cell(self, cell, resources, cell_index): code: Sanitize outputs that could result in code execution """ - if cell.cell_type == "raw": # noqa + if cell.cell_type == "raw": # Sanitize all raw cells anyway. # Only ones with the text/html mimetype should be emitted # but erring on the side of safety maybe. diff --git a/pyproject.toml b/pyproject.toml index 73d4b4a6a..d20ab9cf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -130,7 +130,7 @@ dependencies = [ "black[jupyter]==23.3.0", "mdformat>0.7", "mdformat-gfm>=0.3.5", - "ruff==0.0.276" + "ruff==0.0.281" ] detached = true [tool.hatch.envs.lint.scripts]