@@ -1834,16 +1834,14 @@ def __init__(
18341834
18351835 # add extended theme templates
18361836 extended_templates_dirs = self.get_extended_templates_dirs(self.name)
1837- for templates_dir in extended_templates_dirs:
1838- paths.append(templates_dir / self.theme)
1837+ paths.extend(templates_dir / self.theme for templates_dir in extended_templates_dirs)
18391838
18401839 # add fallback theme templates
18411840 if self.fallback_theme and self.fallback_theme != self.theme:
18421841 paths.append(themes_dir / self.fallback_theme)
18431842
18441843 # add fallback theme of extended templates
1845- for templates_dir in extended_templates_dirs:
1846- paths.append(templates_dir / self.fallback_theme)
1844+ paths.extend(templates_dir / self.fallback_theme for templates_dir in extended_templates_dirs)
18471845
18481846 for path in paths:
18491847 css_path = path / "style.css"
@@ -2081,24 +2079,24 @@ def do_convert_markdown(
20812079 global _markdown_conversion_layer # noqa: PLW0603
20822080 _markdown_conversion_layer += 1
20832081 treeprocessors = self.md.treeprocessors
2084- treeprocessors[HeadingShiftingTreeprocessor.name].shift_by = heading_level # type: ignore[attr-defined]
2085- treeprocessors[IdPrependingTreeprocessor.name].id_prefix = html_id and html_id + "--" # type: ignore[attr-defined]
2086- treeprocessors[ParagraphStrippingTreeprocessor.name].strip = strip_paragraph # type: ignore[attr-defined]
2082+ treeprocessors[HeadingShiftingTreeprocessor.name].shift_by = heading_level
2083+ treeprocessors[IdPrependingTreeprocessor.name].id_prefix = html_id and html_id + "--"
2084+ treeprocessors[ParagraphStrippingTreeprocessor.name].strip = strip_paragraph
20872085 if BacklinksTreeProcessor.name in treeprocessors:
2088- treeprocessors[BacklinksTreeProcessor.name].initial_id = html_id # type: ignore[attr-defined]
2086+ treeprocessors[BacklinksTreeProcessor.name].initial_id = html_id
20892087 if autoref_hook and AutorefsInlineProcessor.name in self.md.inlinePatterns:
2090- self.md.inlinePatterns[AutorefsInlineProcessor.name].hook = autoref_hook # type : ignore[attr-defined ]
2088+ self.md.inlinePatterns[AutorefsInlineProcessor.name].hook = autoref_hook # ty : ignore[unresolved-attribute ]
20912089
20922090 try:
20932091 return Markup(self.md.convert(text))
20942092 finally:
2095- treeprocessors[HeadingShiftingTreeprocessor.name].shift_by = 0 # type: ignore[attr-defined]
2096- treeprocessors[IdPrependingTreeprocessor.name].id_prefix = "" # type: ignore[attr-defined]
2097- treeprocessors[ParagraphStrippingTreeprocessor.name].strip = False # type: ignore[attr-defined]
2093+ treeprocessors[HeadingShiftingTreeprocessor.name].shift_by = 0
2094+ treeprocessors[IdPrependingTreeprocessor.name].id_prefix = ""
2095+ treeprocessors[ParagraphStrippingTreeprocessor.name].strip = False
20982096 if BacklinksTreeProcessor.name in treeprocessors:
2099- treeprocessors[BacklinksTreeProcessor.name].initial_id = None # type: ignore[attr-defined]
2097+ treeprocessors[BacklinksTreeProcessor.name].initial_id = None
21002098 if AutorefsInlineProcessor.name in self.md.inlinePatterns:
2101- self.md.inlinePatterns[AutorefsInlineProcessor.name].hook = None # type: ignore[attr-defined]
2099+ self.md.inlinePatterns[AutorefsInlineProcessor.name].hook = None
21022100 self.md.reset()
21032101 _markdown_conversion_layer -= 1
21042102```
@@ -3113,7 +3111,7 @@ Returns:
31133111Source code in `src/mkdocstrings/_internal/handlers/rendering.py`
31143112
31153113```python
3116- def highlight(
3114+ def highlight( # ty: ignore[invalid-method-override]
31173115 self,
31183116 src: str,
31193117 language: str | None = None,
@@ -3142,7 +3140,7 @@ def highlight(
31423140 src = textwrap.dedent(src)
31433141
31443142 kwargs.setdefault("css_class", self._css_class)
3145- old_linenums = self.linenums # type: ignore[has-type]
3143+ old_linenums = self.linenums
31463144 if linenums is not None:
31473145 self.linenums = linenums
31483146 try:
@@ -3813,7 +3811,7 @@ def log(self, level: int, msg: object, *args: object, **kwargs: object) -> None:
38133811 if (key := (self, str(msg))) in self._logged:
38143812 return
38153813 self._logged.add(key)
3816- super().log(level, msg, *args, **kwargs) # type : ignore[arg -type]
3814+ super().log(level, msg, *args, **kwargs) # ty : ignore[invalid-argument -type]
38173815```
38183816
38193817### process
@@ -3952,7 +3950,7 @@ def extendMarkdown(self, md: Markdown) -> None: # noqa: N802 (casing: parent me
39523950
39533951 # Zensical integration: get the current page from the Zensical-specific preprocessor.
39543952 if "zensical_current_page" in md.preprocessors:
3955- self._autorefs.current_page = md.preprocessors["zensical_current_page"] # type: ignore[assignment]
3953+ self._autorefs.current_page = md.preprocessors["zensical_current_page"]
39563954
39573955 md.parser.blockprocessors.register(
39583956 AutoDocProcessor(md, handlers=self._handlers, autorefs=self._autorefs),
@@ -4259,7 +4257,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
42594257 handlers = Handlers(
42604258 default=self.config.default_handler,
42614259 handlers_config=self.config.handlers,
4262- theme=config.theme.name or os.path.dirname(config.theme.dirs[0]),
4260+ theme=config.theme.name or os.path.dirname(config.theme.dirs[0]), # noqa: PTH120
42634261 custom_templates=self.config.custom_templates,
42644262 mdx=config.markdown_extensions,
42654263 mdx_config=config.mdx_configs,
@@ -4275,7 +4273,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
42754273 autorefs: AutorefsPlugin
42764274 try:
42774275 # If autorefs plugin is explicitly enabled, just use it.
4278- autorefs = config.plugins["autorefs"] # type : ignore[assignment]
4276+ autorefs = config.plugins["autorefs"] # ty : ignore[invalid- assignment]
42794277 _logger.debug("Picked up existing autorefs instance %r", autorefs)
42804278 except KeyError:
42814279 # Otherwise, add a limited instance of it that acts only on what's added through `register_anchor`.
@@ -4286,7 +4284,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
42864284 _logger.debug("Added a subdued autorefs instance %r", autorefs)
42874285
42884286 mkdocstrings_extension = MkdocstringsExtension(handlers, autorefs)
4289- config.markdown_extensions.append(mkdocstrings_extension) # type : ignore[arg -type]
4287+ config.markdown_extensions.append(mkdocstrings_extension) # ty : ignore[invalid-argument -type]
42904288
42914289 config.extra_css.insert(0, self.css_filename) # So that it has lower priority than user files.
42924290
@@ -4796,7 +4794,8 @@ makeExtension(
47964794 inventory_version: str | None = None,
47974795 handlers: dict[str, dict] | None = None,
47984796 custom_templates: str | None = None,
4799- markdown_extensions: list[str | dict] | None = None,
4797+ markdown_extensions: list[str | dict | Extension]
4798+ | None = None,
48004799 locale: str | None = None,
48014800 config_file_path: str | None = None,
48024801) -> MkdocstringsExtension
@@ -4816,7 +4815,7 @@ def makeExtension( # noqa: N802
48164815 inventory_version: str | None = None,
48174816 handlers: dict[str, dict] | None = None,
48184817 custom_templates: str | None = None,
4819- markdown_extensions: list[str | dict] | None = None,
4818+ markdown_extensions: list[str | dict | Extension ] | None = None,
48204819 locale: str | None = None,
48214820 config_file_path: str | None = None,
48224821) -> MkdocstringsExtension:
0 commit comments