diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1102284..5291952 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,14 +20,14 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.12 + rev: v0.16.0 hooks: - id: ruff args: [--fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.20.2 + rev: v2.3.0 hooks: - id: mypy additional_dependencies: [markdown-it-py~=3.0] diff --git a/mdit_py_plugins/admon/index.py b/mdit_py_plugins/admon/index.py index 6e28940..c8933dc 100644 --- a/mdit_py_plugins/admon/index.py +++ b/mdit_py_plugins/admon/index.py @@ -183,7 +183,7 @@ def admonition(state: StateBlock, startLine: int, endLine: int, silent: bool) -> return True -def admon_plugin(md: MarkdownIt, render: None | Callable[..., str] = None) -> None: +def admon_plugin(md: MarkdownIt, render: Callable[..., str] | None = None) -> None: """Plugin to use `python-markdown style admonitions `_. diff --git a/mdit_py_plugins/container/index.py b/mdit_py_plugins/container/index.py index c610268..3338f30 100644 --- a/mdit_py_plugins/container/index.py +++ b/mdit_py_plugins/container/index.py @@ -21,8 +21,8 @@ def container_plugin( md: MarkdownIt, name: str, marker: str = ":", - validate: None | Callable[[str, str], bool] = None, - render: None | Callable[..., str] = None, + validate: Callable[[str, str], bool] | None = None, + render: Callable[..., str] | None = None, ) -> None: """Plugin ported from `markdown-it-container `__. diff --git a/mdit_py_plugins/dollarmath/index.py b/mdit_py_plugins/dollarmath/index.py index 57ba590..43727c1 100644 --- a/mdit_py_plugins/dollarmath/index.py +++ b/mdit_py_plugins/dollarmath/index.py @@ -54,7 +54,7 @@ def dollarmath_plugin( """ if label_normalizer is None: - label_normalizer = lambda label: re.sub(r"\s+", "-", label) # noqa: E731 + label_normalizer = lambda label: re.sub(r"\s+", "-", label) md.inline.ruler.before( "escape", @@ -77,10 +77,8 @@ def dollarmath_plugin( _label_renderer: Callable[[str], str] if label_renderer is None: - _label_renderer = ( # noqa: E731 - lambda label: ( - f'' - ) + _label_renderer = lambda label: ( + f'' ) else: _label_renderer = label_renderer diff --git a/mdit_py_plugins/texmath/index.py b/mdit_py_plugins/texmath/index.py index 67372fa..51525a0 100644 --- a/mdit_py_plugins/texmath/index.py +++ b/mdit_py_plugins/texmath/index.py @@ -86,7 +86,7 @@ class RuleDictType(_RuleDictReqType, total=False): def applyRule( rule: RuleDictType, string: str, begin: int, inBlockquote: bool -) -> None | Match[str]: +) -> Match[str] | None: if not ( string.startswith(rule["tag"], begin) and (rule["pre"](string, begin) if "pre" in rule else True) @@ -202,14 +202,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str: { "name": "math_block_eqno", "rex": re.compile( - r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)", re.M + r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)", + re.MULTILINE, ), "tmpl": '
{0}({1})
', "tag": "\\[", }, { "name": "math_block", - "rex": re.compile(r"^\\\[([\s\S]+?)\\\]", re.M), + "rex": re.compile(r"^\\\[([\s\S]+?)\\\]", re.MULTILINE), "tmpl": "
\n{0}\n
\n", "tag": "\\[", }, @@ -228,14 +229,14 @@ def render(tex: str, displayMode: bool, macros: Any) -> str: { "name": "math_block_eqno", "rex": re.compile( - r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.M + r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE ), "tmpl": '
\n{0}({1})\n
\n', "tag": "```math", }, { "name": "math_block", - "rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.M), + "rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.MULTILINE), "tmpl": "
\n{0}\n
\n", "tag": "```math", }, @@ -270,14 +271,14 @@ def render(tex: str, displayMode: bool, macros: Any) -> str: { "name": "math_block_eqno", "rex": re.compile( - r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.M + r"^`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE ), "tmpl": '
{0}({1})
', "tag": "```math", }, { "name": "math_block", - "rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.M), + "rex": re.compile(r"^`{3}math\s+?([^`]+?)\s+?`{3}", re.MULTILINE), "tmpl": "
{0}
", "tag": "```math", }, @@ -295,13 +296,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str: "block": [ { "name": "math_block_eqno", - "rex": re.compile(r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.M), + "rex": re.compile( + r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE + ), "tmpl": '
{0}({1})
', "tag": "$$", }, { "name": "math_block", - "rex": re.compile(r"^\${2}([^$]*?)\${2}", re.M), + "rex": re.compile(r"^\${2}([^$]*?)\${2}", re.MULTILINE), "tmpl": "
{0}
", "tag": "$$", }, @@ -329,13 +332,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str: "block": [ { "name": "math_block_eqno", - "rex": re.compile(r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.M), + "rex": re.compile( + r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE + ), "tmpl": '
\n{0}({1})\n
\n', "tag": "$$", }, { "name": "math_block", - "rex": re.compile(r"^\${2}([^$]*?)\${2}", re.M), + "rex": re.compile(r"^\${2}([^$]*?)\${2}", re.MULTILINE), "tmpl": "
\n{0}\n
\n", "tag": "$$", },