Skip to content

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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
rev: v0.12.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.0
rev: v1.17.0
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
Expand Down
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
5 changes: 2 additions & 3 deletions myst_parser/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def check_url_schemes(inst: "MdParserConfig", field: dc.Field, value: Any) -> No
if isinstance(value, list | tuple):
if not all(isinstance(v, str) for v in value):
raise TypeError(f"'{field.name}' is not a list of strings: {value!r}")
value = {v: None for v in value}
value = dict.fromkeys(value)

if not isinstance(value, dict):
raise TypeError(f"'{field.name}' is not a dictionary: {value!r}")
Expand Down 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
8 changes: 4 additions & 4 deletions myst_parser/parsers/docutils_.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _validate_url_schemes(
except Exception as err:
raise ValueError("Invalid YAML string") from err
if isinstance(output, str):
output = {k: None for k in output.split(",")}
output = dict.fromkeys(output.split(","))
if not isinstance(output, dict):
raise ValueError("Expecting a comma-delimited str or YAML dictionary")
return output
Expand Down 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"))
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")
else:
self.body.append("</p>\n")

Expand Down
Loading