Skip to content

Commit 1db2b1f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1da5944 commit 1db2b1f

File tree

6 files changed

+15
-20
lines changed

6 files changed

+15
-20
lines changed

myst_parser/_docs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def run(self):
211211
:Name: `{name}`
212212
:Description: {content}
213213
:Arguments: {klass.required_arguments} required, {klass.optional_arguments} optional
214-
:Content: {'yes' if klass.has_content else 'no'}
214+
:Content: {"yes" if klass.has_content else "no"}
215215
:Options:
216216
"""
217217
if klass.option_spec:

myst_parser/config/main.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,7 @@ def merge_file_level(
522522
if "html_meta" in topmatter:
523523
warning(
524524
MystWarnings.MD_TOPMATTER,
525-
"top-level 'html_meta' key is deprecated, "
526-
"place under 'myst' key instead",
525+
"top-level 'html_meta' key is deprecated, place under 'myst' key instead",
527526
)
528527
updates["html_meta"] = topmatter["html_meta"]
529528
if "substitutions" in topmatter:

myst_parser/mdit_to_docutils/base.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,7 @@ def render_link_path(self, token: SyntaxTreeNode) -> None:
976976
def render_link_project(self, token: SyntaxTreeNode) -> None:
977977
"""Render a link token like `<project:...>`."""
978978
destination = cast(str, token.attrGet("href") or "")
979-
if destination.startswith("project:"):
980-
destination = destination[8:]
979+
destination = destination.removeprefix("project:")
981980
if destination.startswith("#"):
982981
return self.render_link_anchor(token, destination)
983982
self.create_warning(
@@ -1796,13 +1795,13 @@ def run_directive(
17961795
)
17971796
return [error_msg]
17981797

1799-
assert isinstance(
1800-
result, list
1801-
), f'Directive "{name}" must return a list of nodes.'
1798+
assert isinstance(result, list), (
1799+
f'Directive "{name}" must return a list of nodes.'
1800+
)
18021801
for i in range(len(result)):
1803-
assert isinstance(
1804-
result[i], nodes.Node
1805-
), f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
1802+
assert isinstance(result[i], nodes.Node), (
1803+
f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
1804+
)
18061805
return result
18071806

18081807
def render_substitution_inline(self, token: SyntaxTreeNode) -> None:

myst_parser/mdit_to_docutils/sphinx_.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def _handle_relative_docs(self, destination: str) -> str:
7272

7373
def render_link_project(self, token: SyntaxTreeNode) -> None:
7474
destination = cast(str, token.attrGet("href") or "")
75-
if destination.startswith("project:"):
76-
destination = destination[8:]
75+
destination = destination.removeprefix("project:")
7776
if destination.startswith("#"):
7877
return self.render_link_anchor(token, destination)
7978

@@ -108,8 +107,7 @@ def render_link_project(self, token: SyntaxTreeNode) -> None:
108107

109108
def render_link_path(self, token: SyntaxTreeNode) -> None:
110109
destination = self.md.normalizeLinkText(cast(str, token.attrGet("href") or ""))
111-
if destination.startswith("path:"):
112-
destination = destination[5:]
110+
destination = destination.removeprefix("path:")
113111
destination = self._handle_relative_docs(destination)
114112
explicit = (token.info != "auto") and (len(token.children or []) > 0)
115113
wrap_node = addnodes.download_reference(

myst_parser/mocking.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ def run(self) -> list[nodes.Element]:
461461
3, ":number-lines: with non-integer start value"
462462
) from err
463463
endline = startline + len(file_content.splitlines())
464-
if file_content.endswith("\n"):
465-
file_content = file_content[:-1]
464+
file_content = file_content.removesuffix("\n")
466465
tokens = NumberLines([([], file_content)], startline, endline)
467466
for classes, value in tokens:
468467
if classes:

myst_parser/parsers/docutils_.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
278278
for i, line in enumerate(inputstring.split("\n")):
279279
if len(line) > document.settings.line_length_limit:
280280
error = document.reporter.error(
281-
f"Line {i+1} exceeds the line-length-limit:"
281+
f"Line {i + 1} exceeds the line-length-limit:"
282282
f" {document.settings.line_length_limit}."
283283
)
284284
document.append(error)
@@ -479,7 +479,7 @@ def visit_rubric_html(self, node):
479479
So here we override the visit/depart methods to output the correct <h> element
480480
"""
481481
if "level" in node:
482-
self.body.append(self.starttag(node, f'h{node["level"]}', "", CLASS="rubric"))
482+
self.body.append(self.starttag(node, f"h{node['level']}", "", CLASS="rubric"))
483483
else:
484484
self.body.append(self.starttag(node, "p", "", CLASS="rubric"))
485485

@@ -490,7 +490,7 @@ def depart_rubric_html(self, node):
490490
See explanation in `visit_rubric_html`
491491
"""
492492
if "level" in node:
493-
self.body.append(f'</h{node["level"]}>\n')
493+
self.body.append(f"</h{node['level']}>\n")
494494
else:
495495
self.body.append("</p>\n")
496496

0 commit comments

Comments
 (0)