@@ -140,7 +140,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
140140 handlers = Handlers (
141141 default = self .config .default_handler ,
142142 handlers_config = self .config .handlers ,
143- theme = config .theme .name or os .path .dirname (config .theme .dirs [0 ]),
143+ theme = config .theme .name or os .path .dirname (config .theme .dirs [0 ]), # noqa: PTH120
144144 custom_templates = self .config .custom_templates ,
145145 mdx = config .markdown_extensions ,
146146 mdx_config = config .mdx_configs ,
@@ -156,7 +156,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
156156 autorefs : AutorefsPlugin
157157 try :
158158 # If autorefs plugin is explicitly enabled, just use it.
159- autorefs = config .plugins ["autorefs" ] # type : ignore[assignment]
159+ autorefs = config .plugins ["autorefs" ] # ty : ignore[invalid- assignment]
160160 _logger .debug ("Picked up existing autorefs instance %r" , autorefs )
161161 except KeyError :
162162 # Otherwise, add a limited instance of it that acts only on what's added through `register_anchor`.
@@ -167,7 +167,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
167167 _logger .debug ("Added a subdued autorefs instance %r" , autorefs )
168168
169169 mkdocstrings_extension = MkdocstringsExtension (handlers , autorefs )
170- config .markdown_extensions .append (mkdocstrings_extension ) # type : ignore[arg -type]
170+ config .markdown_extensions .append (mkdocstrings_extension ) # ty : ignore[invalid-argument -type]
171171
172172 config .extra_css .insert (0 , self .css_filename ) # So that it has lower priority than user files.
173173
@@ -199,22 +199,22 @@ def plugin_enabled(self) -> bool:
199199 @event_priority (50 ) # Early, before autorefs' starts applying cross-refs and collecting backlinks.
200200 def _on_env_load_inventories (self , env : Environment , config : MkDocsConfig , * args : Any , ** kwargs : Any ) -> None : # noqa: ARG002
201201 if self .plugin_enabled and self ._handlers :
202- register = config .plugins ["autorefs" ].register_url # type : ignore[attr-defined ]
202+ register = config .plugins ["autorefs" ].register_url # ty : ignore[possibly-missing-attribute ]
203203 for identifier , url in self ._handlers ._yield_inventory_items ():
204204 register (identifier , url )
205205
206206 @event_priority (- 20 ) # Late, not important.
207207 def _on_env_add_css (self , env : Environment , config : MkDocsConfig , * args : Any , ** kwargs : Any ) -> None : # noqa: ARG002
208208 if self .plugin_enabled and self ._handlers :
209209 css_content = "\n " .join (handler .extra_css for handler in self .handlers .seen_handlers )
210- write_file (css_content .encode ("utf-8" ), os .path .join (config .site_dir , self .css_filename ))
210+ write_file (css_content .encode ("utf-8" ), os .path .join (config .site_dir , self .css_filename )) # noqa: PTH118
211211
212212 @event_priority (- 20 ) # Late, not important.
213213 def _on_env_write_inventory (self , env : Environment , config : MkDocsConfig , * args : Any , ** kwargs : Any ) -> None : # noqa: ARG002
214214 if self .plugin_enabled and self ._handlers and self .inventory_enabled :
215215 _logger .debug ("Creating inventory file objects.inv" )
216216 inv_contents = self .handlers .inventory .format_sphinx ()
217- write_file (inv_contents , os .path .join (config .site_dir , "objects.inv" ))
217+ write_file (inv_contents , os .path .join (config .site_dir , "objects.inv" )) # noqa: PTH118
218218
219219 @event_priority (- 100 ) # Last, after autorefs has finished applying cross-refs and collecting backlinks.
220220 def _on_env_apply_backlinks (self , env : Environment , / , * , config : MkDocsConfig , files : Files ) -> Environment : # noqa: ARG002
@@ -226,12 +226,12 @@ def repl(match: Match) -> str:
226226
227227 # The handler doesn't implement backlinks,
228228 # return early to avoid computing them.
229- if handler .render_backlinks .__func__ is BaseHandler .render_backlinks : # type: ignore[attr-defined]
229+ if handler .render_backlinks .__func__ is BaseHandler .render_backlinks :
230230 return ""
231231
232232 identifier = match .group (1 )
233233 aliases = handler .get_aliases (identifier )
234- backlinks = self ._autorefs .get_backlinks (identifier , * aliases , from_url = file .page .url ) # type: ignore[union-attr]
234+ backlinks = self ._autorefs .get_backlinks (identifier , * aliases , from_url = file .page .url )
235235
236236 # No backlinks, avoid calling the handler's method.
237237 if not backlinks :
@@ -240,7 +240,7 @@ def repl(match: Match) -> str:
240240 if "locale" in signature (handler .render_backlinks ).parameters :
241241 render_backlinks = partial (handler .render_backlinks , locale = self .handlers ._locale )
242242 else :
243- render_backlinks = handler .render_backlinks # type: ignore[assignment]
243+ render_backlinks = handler .render_backlinks
244244
245245 return render_backlinks (backlinks )
246246
0 commit comments