Skip to content

Commit 8992c96

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

11 files changed

Lines changed: 21 additions & 24 deletions

File tree

myst_parser/_docs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ def run(self):
404404
### MyST Lexer ###
405405
# TODO when some more work and testing, this should be made available publicly
406406

407-
from pygments import token # noqa: E402
408-
from pygments.lexer import bygroups, inherit, this, using # noqa: E402
409-
from pygments.lexers.markup import MarkdownLexer # noqa: E402
407+
from pygments import token
408+
from pygments.lexer import bygroups, inherit, this, using
409+
from pygments.lexers.markup import MarkdownLexer
410410

411411

412412
class MystLexer(MarkdownLexer):

myst_parser/inventory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def filter_string(
411411

412412

413413
def fetch_inventory(
414-
uri: str, *, timeout: None | float = None, base_url: None | str = None
414+
uri: str, *, timeout: float | None = None, base_url: str | None = None
415415
) -> InventoryType:
416416
"""Fetch an inventory from a URL or local path."""
417417
if uri.startswith(("http://", "https://")):
@@ -421,7 +421,7 @@ def fetch_inventory(
421421
return load(stream, base_url=base_url)
422422

423423

424-
def inventory_cli(inputs: None | list[str] = None):
424+
def inventory_cli(inputs: list[str] | None = None):
425425
"""Command line interface for fetching and parsing an inventory."""
426426
parser = argparse.ArgumentParser(description="Parse an inventory file.")
427427
parser.add_argument("uri", metavar="[URL|PATH]", help="URI of the inventory file")

myst_parser/mdit_to_docutils/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __init__(self, parser: MarkdownIt) -> None:
112112
if k.startswith("render_") and k != "render_children"
113113
}
114114
# these are lazy loaded, when needed
115-
self._inventories: None | dict[str, inventory.InventoryType] = None
115+
self._inventories: dict[str, inventory.InventoryType] | None = None
116116

117117
def __getattr__(self, name: str):
118118
"""Warn when the renderer has not been setup yet."""
@@ -300,7 +300,7 @@ def nested_render_text(
300300
text: str,
301301
lineno: int,
302302
inline: bool = False,
303-
temp_root_node: None | nodes.Element = None,
303+
temp_root_node: nodes.Element | None = None,
304304
heading_offset: int = 0,
305305
) -> None:
306306
"""Render unparsed text (appending to the current node).
@@ -988,7 +988,7 @@ def render_link(self, token: SyntaxTreeNode) -> None:
988988
return self.render_link_unknown(token)
989989

990990
def render_link_url(
991-
self, token: SyntaxTreeNode, conversion: None | UrlSchemeType = None
991+
self, token: SyntaxTreeNode, conversion: UrlSchemeType | None = None
992992
) -> None:
993993
"""Render link token (including autolink and linkify),
994994
where the link has been identified as an external URL.
@@ -2113,7 +2113,7 @@ def default_slugify(title: str) -> str:
21132113
def compute_unique_slug(
21142114
token_tree: SyntaxTreeNode,
21152115
slugs: Container[str],
2116-
slug_func: None | Callable[[str], str] = None,
2116+
slug_func: Callable[[str], str] | None = None,
21172117
) -> str:
21182118
"""Compute the slug for a heading token, unique against existing slugs."""
21192119
slug_func = github_slugify if slug_func is None else slug_func

myst_parser/mdit_to_docutils/sphinx_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def render_link_unknown(self, token: SyntaxTreeNode) -> None:
136136
path_dest, *_path_ids = destination.split("#", maxsplit=1)
137137
path_id = _path_ids[0] if _path_ids else None
138138

139-
potential_path: None | Path = None
139+
potential_path: Path | None = None
140140
if self.sphinx_env.srcdir: # not set in some test situations
141141
_, path_str = self.sphinx_env.relfn2path(path_dest, self.sphinx_env.docname)
142142
potential_path = Path(path_str)

myst_parser/mdit_to_docutils/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def apply(self, **kwargs: t.Any) -> None:
218218

219219
# gather explicit references
220220
# this follows the same logic as Sphinx's StandardDomain.process_doc
221-
explicit: dict[str, tuple[str, None | str]] = {}
221+
explicit: dict[str, tuple[str, str | None]] = {}
222222
for name, is_explicit in self.document.nametypes.items():
223223
if not is_explicit:
224224
continue

myst_parser/parsers/directives.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _parse_directive_options(
198198
:param additional_options: Additional options for the directive,
199199
which the options block takes priority over
200200
"""
201-
options_block: None | str = None
201+
options_block: str | None = None
202202
options_position: int | None = None
203203
"""The 1-based source line of the first line of the options block."""
204204
if content.startswith("---"):

myst_parser/parsers/docutils_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
321321
pass # this will be reported during the render
322322
else:
323323
if topmatter:
324-
warning = lambda wtype, msg: create_warning( # noqa: E731
324+
warning = lambda wtype, msg: create_warning(
325325
document, msg, wtype, line=1, append_to=document
326326
)
327327
config = merge_file_level(config, topmatter, warning)

myst_parser/parsers/options.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,7 @@ def _scan_block_scalar(
530530

531531
# Determine the indentation level and go to the first non-empty line.
532532
min_indent = indent + 1
533-
if min_indent < 1:
534-
min_indent = 1
533+
min_indent = max(min_indent, 1)
535534
if increment is None:
536535
breaks, max_indent, end_mark = _scan_block_scalar_indentation(stream)
537536
indent = max(min_indent, max_indent)
@@ -652,8 +651,7 @@ def _scan_block_scalar_indentation(
652651
end_mark = stream.get_position()
653652
else:
654653
stream.forward()
655-
if stream.column > max_indent:
656-
max_indent = stream.column
654+
max_indent = max(max_indent, stream.column)
657655
return chunks, max_indent, end_mark
658656

659657

myst_parser/parsers/parse_html.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from collections import abc, deque
2626
from collections.abc import Callable, Iterable, Iterator
2727
from html.parser import HTMLParser
28-
from typing import Any
2928

3029

3130
class Attribute(dict):
@@ -138,7 +137,7 @@ def render(
138137
def __str__(self) -> str:
139138
return self.render()
140139

141-
def __eq__(self, item: Any) -> bool:
140+
def __eq__(self, item: object) -> bool:
142141
return item is self
143142

144143
def walk(self, include_self: bool = False) -> Iterator[Element]:

myst_parser/parsers/sphinx_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
7777
pass # this will be reported during the render
7878
else:
7979
if topmatter:
80-
warning = lambda wtype, msg: create_warning( # noqa: E731
80+
warning = lambda wtype, msg: create_warning(
8181
document, msg, wtype, line=1, append_to=document
8282
)
8383
config = merge_file_level(config, topmatter, warning)

0 commit comments

Comments
 (0)