Skip to content

Commit 3860152

Browse files
[pre-commit.ci] pre-commit autoupdate (#1971)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
1 parent 946de57 commit 3860152

19 files changed

+40
-28
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: trailing-whitespace
2020

2121
- repo: https://github.com/python-jsonschema/check-jsonschema
22-
rev: 0.21.0
22+
rev: 0.22.0
2323
hooks:
2424
- id: check-github-workflows
2525

@@ -31,12 +31,12 @@ repos:
3131
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
3232

3333
- repo: https://github.com/psf/black
34-
rev: 23.1.0
34+
rev: 23.3.0
3535
hooks:
3636
- id: black
3737

3838
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: v0.0.254
39+
rev: v0.0.260
4040
hooks:
4141
- id: ruff
4242
args: ["--fix"]

hatch_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _get_css_file(template_name, url, filename):
4747
os.makedirs(directory)
4848
print("Downloading CSS: %s" % url)
4949
try:
50-
css = urlopen(url).read()
50+
css = urlopen(url).read() # noqa
5151
except Exception as e:
5252
msg = f"Failed to download css from {url}: {e}"
5353
print(msg, file=sys.stderr)

nbconvert/exporters/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def from_filename(
179179
# Pull the metadata from the filesystem.
180180
if resources is None:
181181
resources = ResourcesDict()
182-
if "metadata" not in resources or resources["metadata"] == "":
182+
if "metadata" not in resources or resources["metadata"] == "": # noqa
183183
resources["metadata"] = ResourcesDict()
184184
path, basename = os.path.split(filename)
185185
notebook_name = os.path.splitext(basename)[0]

nbconvert/exporters/slides.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def _reveal_url_prefix_default(self):
124124
if "RevealHelpPreprocessor.url_prefix" in self.config:
125125
warn(
126126
"Please update RevealHelpPreprocessor.url_prefix to "
127-
"SlidesExporter.reveal_url_prefix in config files."
127+
"SlidesExporter.reveal_url_prefix in config files.",
128+
stacklevel=2,
128129
)
129130
return self.config.RevealHelpPreprocessor.url_prefix
130131
return "https://unpkg.com/reveal.js@4.0.2"

nbconvert/exporters/templateexporter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def recursive_update(target, new):
104104
# define function at the top level to avoid pickle errors
105105
def deprecated(msg):
106106
"""Emit a deprecation warning."""
107-
warnings.warn(msg, DeprecationWarning)
107+
warnings.warn(msg, DeprecationWarning, stacklevel=2)
108108

109109

110110
class ExtensionTolerantLoader(BaseLoader):
@@ -210,6 +210,7 @@ def _template_name_validate(self, change):
210210
warnings.warn(
211211
f"5.x style template name passed '{self.template_name}'. Use --template-name for the template directory with a index.<ext>.j2 file and/or --template-file to denote a different template.",
212212
DeprecationWarning,
213+
stacklevel=2,
213214
)
214215
directory, self.template_file = os.path.split(self.template_name)
215216
if directory:
@@ -235,6 +236,7 @@ def _template_file_changed(self, change):
235236
warnings.warn(
236237
f"5.x style template file passed '{new}'. Use --template-name for the template directory with a index.<ext>.j2 file and/or --template-file to denote a different template.",
237238
DeprecationWarning,
239+
stacklevel=2,
238240
)
239241

240242
@default("template_file")
@@ -597,7 +599,7 @@ def get_compatibility_base_template_conf(cls, name):
597599
if name == "full":
598600
return {"base_template": "classic", "mimetypes": {"text/html": True}}
599601

600-
def get_template_names(self):
602+
def get_template_names(self): # noqa
601603
"""Finds a list of template names where each successive template name is the base template"""
602604
template_names = []
603605
root_dirs = self.get_prefix_root_dirs()
@@ -635,6 +637,7 @@ def get_template_names(self):
635637
warnings.warn(
636638
f"5.x template name passed '{self.template_name}'. Use 'lab' or 'classic' for new template usage.",
637639
DeprecationWarning,
640+
stacklevel=2,
638641
)
639642
self.template_file = compatibility_file
640643
conf = self.get_compatibility_base_template_conf(base_template)

nbconvert/filters/ansi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def ansi2latex(text):
7171
return _ansi2anything(text, _latexconverter)
7272

7373

74-
def _htmlconverter(fg, bg, bold, underline, inverse):
74+
def _htmlconverter(fg, bg, bold, underline, inverse): # noqa
7575
"""
7676
Return start and end tags for given foreground/background/bold/underline.
7777
@@ -114,7 +114,7 @@ def _htmlconverter(fg, bg, bold, underline, inverse):
114114
return starttag, "</span>"
115115

116116

117-
def _latexconverter(fg, bg, bold, underline, inverse):
117+
def _latexconverter(fg, bg, bold, underline, inverse): # noqa
118118
"""
119119
Return start and end markup given foreground/background/bold/underline.
120120
@@ -133,7 +133,7 @@ def _latexconverter(fg, bg, bold, underline, inverse):
133133
elif fg:
134134
# See http://tex.stackexchange.com/a/291102/13684
135135
starttag += r"\def\tcRGB{\textcolor[RGB]}\expandafter"
136-
starttag += r"\tcRGB\expandafter{\detokenize{%s,%s,%s}}{" % fg
136+
starttag += r"\tcRGB\expandafter{{\detokenize{{{},{},{}}}}}{{".format(*fg)
137137
endtag = "}" + endtag
138138
elif inverse:
139139
starttag += r"\textcolor{ansi-default-inverse-fg}{"
@@ -147,7 +147,7 @@ def _latexconverter(fg, bg, bold, underline, inverse):
147147
starttag += r"\setlength{\fboxsep}{0pt}"
148148
# See http://tex.stackexchange.com/a/291102/13684
149149
starttag += r"\def\cbRGB{\colorbox[RGB]}\expandafter"
150-
starttag += r"\cbRGB\expandafter{\detokenize{%s,%s,%s}}{" % bg
150+
starttag += r"\cbRGB\expandafter{{\detokenize{{{},{},{}}}}}{{".format(*bg)
151151
endtag = r"\strut}" + endtag
152152
elif inverse:
153153
starttag += r"\setlength{\fboxsep}{0pt}"

nbconvert/filters/datatypefilter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def __call__(self, output):
4040
return [fmt]
4141
warn(
4242
"Your element with mimetype(s) {mimetypes}"
43-
" is not able to be represented.".format(mimetypes=output.keys())
43+
" is not able to be represented.".format(mimetypes=output.keys()),
44+
stacklevel=2,
4445
)
4546

4647
return []

nbconvert/filters/highlight.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def __init__(self, pygments_lexer=None, **kwargs):
4646
def _default_language_changed(self, change):
4747
warn(
4848
"Setting default_language in config is deprecated as of 5.0, "
49-
"please use language_info metadata instead."
49+
"please use language_info metadata instead.",
50+
stacklevel=2,
5051
)
5152
self.pygments_lexer = change["new"]
5253

@@ -102,7 +103,8 @@ def __init__(self, pygments_lexer=None, **kwargs):
102103
def _default_language_changed(self, change):
103104
warn(
104105
"Setting default_language in config is deprecated as of 5.0, "
105-
"please use language_info metadata instead."
106+
"please use language_info metadata instead.",
107+
stacklevel=2,
106108
)
107109
self.pygments_lexer = change["new"]
108110

@@ -164,15 +166,15 @@ def _pygments_highlight(source, output_formatter, language="ipython", metadata=N
164166
try:
165167
from IPython.lib.lexers import IPythonLexer
166168
except ImportError:
167-
warn("IPython lexer unavailable, falling back on Python")
169+
warn("IPython lexer unavailable, falling back on Python", stacklevel=2)
168170
language = "python"
169171
else:
170172
lexer = IPythonLexer()
171173
elif language == "ipython3":
172174
try:
173175
from IPython.lib.lexers import IPython3Lexer
174176
except ImportError:
175-
warn("IPython3 lexer unavailable, falling back on Python 3")
177+
warn("IPython3 lexer unavailable, falling back on Python 3", stacklevel=2)
176178
language = "python3"
177179
else:
178180
lexer = IPython3Lexer()
@@ -181,7 +183,7 @@ def _pygments_highlight(source, output_formatter, language="ipython", metadata=N
181183
try:
182184
lexer = get_lexer_by_name(language, stripall=True)
183185
except ClassNotFound:
184-
warn("No lexer found for language %r. Treating as plain text." % language)
186+
warn("No lexer found for language %r. Treating as plain text." % language, stacklevel=2)
185187
from pygments.lexers.special import TextLexer
186188

187189
lexer = TextLexer()

nbconvert/filters/strings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def ipython2python(code):
234234
except ImportError:
235235
warnings.warn(
236236
"IPython is needed to transform IPython syntax to pure Python."
237-
" Install ipython if you need this functionality."
237+
" Install ipython if you need this functionality.",
238+
stacklevel=2,
238239
)
239240
return code
240241
else:

nbconvert/filters/tests/test_highlight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_parse_html_many_lang(self):
7070
rb = highlight2html_ruby(self.tests[0])
7171

7272
for lang, tkns in [(ht, ("def",)), (rb, ("def", "end"))]:
73-
root = xml.etree.ElementTree.fromstring(lang)
73+
root = xml.etree.ElementTree.fromstring(lang) # noqa
7474
self.assertEqual(self._extract_tokens(root, "k"), set(tkns))
7575

7676
@pytest.mark.filterwarnings("ignore")

nbconvert/filters/widgetsdatatypefilter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def __call__(self, output):
7171
return [fmt]
7272
warn(
7373
"Your element with mimetype(s) {mimetypes}"
74-
" is not able to be represented.".format(mimetypes=output.keys())
74+
" is not able to be represented.".format(mimetypes=output.keys()),
75+
stacklevel=2,
7576
)
7677

7778
return []

nbconvert/nbconvertapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def init_writer(self):
399399
"""Initialize the writer (which is stateless)"""
400400
self._writer_class_changed({"new": self.writer_class})
401401
self.writer = self.writer_factory(parent=self)
402-
if hasattr(self.writer, "build_directory") and self.writer.build_directory != "":
402+
if hasattr(self.writer, "build_directory") and self.writer.build_directory != "": # noqa
403403
self.use_output_suffix = False
404404

405405
def init_postprocessor(self):

nbconvert/preprocessors/execute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def executenb(*args, **kwargs):
2424
"The 'nbconvert.preprocessors.execute.executenb' function was moved to nbclient.execute. "
2525
"We recommend importing that library directly.",
2626
FutureWarning,
27+
stacklevel=2,
2728
)
2829
return _execute(*args, **kwargs)
2930

nbconvert/preprocessors/sanitize.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
warnings.warn(
3131
"Support for bleach <5 will be removed in a future version of nbconvert",
3232
DeprecationWarning,
33+
stacklevel=2,
3334
)
3435

3536
except ImportError:
3637
warnings.warn(
3738
"The installed bleach/tinycss2 do not provide CSS sanitization, "
3839
"please upgrade to bleach >=5",
3940
UserWarning,
41+
stacklevel=2,
4042
)
4143

4244

nbconvert/utils/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def link_or_copy(src, dst):
103103
# anyway, we get duplicate files - see http://bugs.python.org/issue21876
104104
return
105105

106-
new_dst = dst + f"-temp-{random.randint(1, 16**4):04X}"
106+
new_dst = dst + f"-temp-{random.randint(1, 16**4):04X}" # noqa
107107
try:
108108
link_or_copy(src, new_dst)
109109
except BaseException:

nbconvert/utils/lexers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Deprecated as of 5.0; import from IPython.lib.lexers instead."""
22
from warnings import warn
33

4-
warn("nbconvert.utils.lexers is deprecated as of 5.0. Use IPython.lib.lexers")
4+
warn("nbconvert.utils.lexers is deprecated as of 5.0. Use IPython.lib.lexers", stacklevel=2)
55

66
from IPython.lib.lexers import * # noqa

nbconvert/writers/debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def write(self, output, resources, notebook_name="notebook", **kw):
3939
if isinstance(resources["outputs"], dict):
4040
print("outputs extracted from %s" % notebook_name)
4141
print("-" * 80)
42-
pprint(resources["outputs"], indent=2, width=70)
42+
pprint(resources["outputs"], indent=2, width=70) # noqa
4343
else:
4444
print("no outputs extracted from %s" % notebook_name)
4545
print("=" * 80)

nbconvert/writers/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def write(self, output, resources, notebook_name=None, **kw):
100100
# Copy files that match search pattern
101101
for matching_filename in glob.glob(filename):
102102
# compute the relative path for the filename
103-
if relpath != "":
103+
if relpath != "": # noqa
104104
dest_filename = os.path.relpath(matching_filename, relpath)
105105
else:
106106
dest_filename = matching_filename

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ test = "mypy --install-types --non-interactive {args:nbconvert}"
126126

127127
[tool.hatch.envs.lint]
128128
dependencies = [
129-
"black[jupyter]==23.1.0",
129+
"black[jupyter]==23.3.0",
130130
"mdformat>0.7",
131131
"mdformat-gfm>=0.3.5",
132-
"ruff==0.0.254"
132+
"ruff==0.0.260"
133133
]
134134
detached = true
135135
[tool.hatch.envs.lint.scripts]

0 commit comments

Comments
 (0)