Skip to content
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

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

Merged
merged 7 commits into from
Aug 1, 2023
Merged
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"]
3 changes: 2 additions & 1 deletion nbconvert/exporters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion nbconvert/exporters/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion nbconvert/filters/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nbconvert/filters/markdown_mistune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 6 additions & 10 deletions nbconvert/nbconvertapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion nbconvert/preprocessors/sanitize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down