Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent af215ac commit 7208b2d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion myst_parser/_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def run(self):
:Name: `{name}`
:Description: {content}
:Arguments: {klass.required_arguments} required, {klass.optional_arguments} optional
:Content: {'yes' if klass.has_content else 'no'}
:Content: {"yes" if klass.has_content else "no"}
:Options:
"""
if klass.option_spec:
Expand Down
3 changes: 1 addition & 2 deletions myst_parser/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,7 @@ def merge_file_level(
if "html_meta" in topmatter:
warning(
MystWarnings.MD_TOPMATTER,
"top-level 'html_meta' key is deprecated, "
"place under 'myst' key instead",
"top-level 'html_meta' key is deprecated, place under 'myst' key instead",
)
updates["html_meta"] = topmatter["html_meta"]
if "substitutions" in topmatter:
Expand Down
15 changes: 7 additions & 8 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,7 @@ def render_link_path(self, token: SyntaxTreeNode) -> None:
def render_link_project(self, token: SyntaxTreeNode) -> None:
"""Render a link token like `<project:...>`."""
destination = cast(str, token.attrGet("href") or "")
if destination.startswith("project:"):
destination = destination[8:]
destination = destination.removeprefix("project:")
if destination.startswith("#"):
return self.render_link_anchor(token, destination)
self.create_warning(
Expand Down Expand Up @@ -1796,13 +1795,13 @@ def run_directive(
)
return [error_msg]

assert isinstance(
result, list
), f'Directive "{name}" must return a list of nodes.'
assert isinstance(result, list), (
f'Directive "{name}" must return a list of nodes.'
)
for i in range(len(result)):
assert isinstance(
result[i], nodes.Node
), f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
assert isinstance(result[i], nodes.Node), (
f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
)
return result

def render_substitution_inline(self, token: SyntaxTreeNode) -> None:
Expand Down
6 changes: 2 additions & 4 deletions myst_parser/mdit_to_docutils/sphinx_.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def _handle_relative_docs(self, destination: str) -> str:

def render_link_project(self, token: SyntaxTreeNode) -> None:
destination = cast(str, token.attrGet("href") or "")
if destination.startswith("project:"):
destination = destination[8:]
destination = destination.removeprefix("project:")
if destination.startswith("#"):
return self.render_link_anchor(token, destination)

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

def render_link_path(self, token: SyntaxTreeNode) -> None:
destination = self.md.normalizeLinkText(cast(str, token.attrGet("href") or ""))
if destination.startswith("path:"):
destination = destination[5:]
destination = destination.removeprefix("path:")
destination = self._handle_relative_docs(destination)
explicit = (token.info != "auto") and (len(token.children or []) > 0)
wrap_node = addnodes.download_reference(
Expand Down
3 changes: 1 addition & 2 deletions myst_parser/mocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ def run(self) -> list[nodes.Element]:
3, ":number-lines: with non-integer start value"
) from err
endline = startline + len(file_content.splitlines())
if file_content.endswith("\n"):
file_content = file_content[:-1]
file_content = file_content.removesuffix("\n")
tokens = NumberLines([([], file_content)], startline, endline)
for classes, value in tokens:
if classes:
Expand Down
6 changes: 3 additions & 3 deletions myst_parser/parsers/docutils_.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
for i, line in enumerate(inputstring.split("\n")):
if len(line) > document.settings.line_length_limit:
error = document.reporter.error(
f"Line {i+1} exceeds the line-length-limit:"
f"Line {i + 1} exceeds the line-length-limit:"
f" {document.settings.line_length_limit}."
)
document.append(error)
Expand Down Expand Up @@ -479,7 +479,7 @@ def visit_rubric_html(self, node):
So here we override the visit/depart methods to output the correct <h> element
"""
if "level" in node:
self.body.append(self.starttag(node, f'h{node["level"]}', "", CLASS="rubric"))
self.body.append(self.starttag(node, f"h{node['level']}", "", CLASS="rubric"))

Check warning on line 482 in myst_parser/parsers/docutils_.py

View check run for this annotation

Codecov / codecov/patch

myst_parser/parsers/docutils_.py#L482

Added line #L482 was not covered by tests
else:
self.body.append(self.starttag(node, "p", "", CLASS="rubric"))

Expand All @@ -490,7 +490,7 @@ def depart_rubric_html(self, node):
See explanation in `visit_rubric_html`
"""
if "level" in node:
self.body.append(f'</h{node["level"]}>\n')
self.body.append(f"</h{node['level']}>\n")

Check warning on line 493 in myst_parser/parsers/docutils_.py

View check run for this annotation

Codecov / codecov/patch

myst_parser/parsers/docutils_.py#L493

Added line #L493 was not covered by tests
else:
self.body.append("</p>\n")

Expand Down

0 comments on commit 7208b2d

Please sign in to comment.