chore: switch to ty

Signed-off-by: Timothée Mazzucotelli <dev@pawamoy.fr>
This commit is contained in:
Timothée Mazzucotelli
2026-04-24 17:14:04 +00:00
committed by GitHub
parent c937ed3c4d
commit dfb73ff1f3
11 changed files with 104 additions and 218 deletions
+3 -3
View File
@@ -23,6 +23,6 @@
from zensical.zensical import * # noqa: F403
__doc__ = zensical.__doc__ # type: ignore[name-defined] # noqa: F405
if hasattr(zensical, "__all__"): # type: ignore[name-defined] # noqa: F405
__all__ = zensical.__all__ # type: ignore[name-defined] # noqa: F405
__doc__ = zensical.__doc__ # noqa: F405
if hasattr(zensical, "__all__"): # noqa: F405
__all__ = zensical.__all__ # noqa: F405
+7 -3
View File
@@ -26,7 +26,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from mkdocs_autorefs import AutorefsExtension
from mkdocs_autorefs import ( # ty:ignore[unresolved-import]
AutorefsExtension,
)
# ----------------------------------------------------------------------------
@@ -96,10 +98,12 @@ def get_autorefs_plugin() -> AutorefsPlugin:
def get_autorefs_extension() -> AutorefsExtension | None:
"""Get the MkDocs Autorefs extension."""
try:
from mkdocs_autorefs import AutorefsExtension # noqa: PLC0415
from mkdocs_autorefs import ( # ty:ignore[unresolved-import] # noqa: PLC0415
AutorefsExtension,
)
except ImportError:
return None
return AutorefsExtension(get_autorefs_plugin()) # type: ignore[arg-type,unused-ignore]
return AutorefsExtension(get_autorefs_plugin())
def set_autorefs_page(url: str, path: str) -> None:
+8 -2
View File
@@ -28,7 +28,10 @@ from typing import TYPE_CHECKING, Any
from zensical.compat.autorefs import get_autorefs_plugin
if TYPE_CHECKING:
from mkdocstrings import Handlers, MkdocstringsExtension
from mkdocstrings import ( # ty:ignore[unresolved-import]
Handlers,
MkdocstringsExtension,
)
# ----------------------------------------------------------------------------
@@ -55,7 +58,10 @@ def get_mkdocstrings_extension(
path: str,
) -> MkdocstringsExtension:
"""Create the mkdocstrings Markdown extension."""
from mkdocstrings import Handlers, MkdocstringsExtension # noqa: PLC0415
from mkdocstrings import ( # noqa: PLC0415 # ty:ignore[unresolved-import]
Handlers,
MkdocstringsExtension,
)
autorefs = get_autorefs_plugin()
+2 -2
View File
@@ -114,7 +114,7 @@ def parse_mkdocs_config(path: str) -> dict:
def get_config() -> dict:
"""Return configuration."""
# We assume this function is only called after populating `_CONFIG`.
return _CONFIG # type: ignore[return-value]
return _CONFIG # ty:ignore[invalid-return-type]
@functools.cache
@@ -539,7 +539,7 @@ def _apply_defaults(config: dict, path: str) -> dict:
if "glightbox" in config["plugins"]:
plugin = config["plugins"]["glightbox"]["config"]
config["markdown_extensions"].append(
glightbox.makeExtension(
glightbox.makeExtension( # ty:ignore[invalid-argument-type]
width=plugin.get("width"),
height=plugin.get("height"),
skip_classes=plugin.get("skip_classes"),
+1 -1
View File
@@ -58,7 +58,7 @@ def to_svg(
) -> Element[str]:
"""Load icon."""
if not uc:
icons = md.inlinePatterns["emoji"].emoji_index["emoji"] # type: ignore[attr-defined]
icons = md.inlinePatterns["emoji"].emoji_index["emoji"] # ty:ignore[unresolved-attribute]
# Create and return element to host icon
el = Element("span", {"class": options.get("classes", index)})
+3 -3
View File
@@ -40,11 +40,11 @@ class SearchProcessor(Postprocessor):
super().__init__(md)
self.data: list[dict[str, Any]] = []
def run(self, html: str) -> str:
def run(self, text: str) -> str:
"""Process the rendered HTML and extract text length."""
# Divide page content into sections
parser = Parser()
parser.feed(html)
parser.feed(text)
parser.close()
# Extract data from sections that are not excluded
@@ -68,7 +68,7 @@ class SearchProcessor(Postprocessor):
)
# Return the original HTML unchanged
return html
return text
class SearchExtension(Extension):
+1 -1
View File
@@ -113,7 +113,7 @@ def render(content: str, path: str, url: str) -> dict:
meta[key] = value.isoformat()
# Obtain search index data, unless page is excluded
search_processor: SearchProcessor = md.postprocessors["search"] # type: ignore[assignment]
search_processor: SearchProcessor = md.postprocessors["search"]
if meta.get("search", {}).get("exclude", False):
search_processor.data = []