@@ -56,7 +56,12 @@ class AutoDocProcessor(BlockProcessor):
5656 regex = re .compile (r"^(?P<heading>#{1,6} *|)::: ?(?P<name>.+?) *$" , flags = re .MULTILINE )
5757
5858 def __init__ (
59- self , parser : BlockParser , md : Markdown , config : dict , handlers : Handlers , autorefs : AutorefsPlugin
59+ self ,
60+ parser : BlockParser ,
61+ md : Markdown ,
62+ config : dict ,
63+ handlers : Handlers ,
64+ autorefs : AutorefsPlugin ,
6065 ) -> None :
6166 """Initialize the object.
6267
@@ -75,7 +80,7 @@ def __init__(
7580 self ._autorefs = autorefs
7681 self ._updated_envs : set = set ()
7782
78- def test (self , parent : Element , block : str ) -> bool :
83+ def test (self , parent : Element , block : str ) -> bool : # noqa: ARG002
7984 """Match our autodoc instructions.
8085
8186 Arguments:
@@ -124,15 +129,15 @@ def run(self, parent: Element, blocks: MutableSequence[str]) -> None:
124129 page = self ._autorefs .current_page
125130 if page :
126131 for heading in headings :
127- anchor = heading .attrib ["id" ] # noqa: WPS440
128- self ._autorefs .register_anchor (page , anchor ) # noqa: WPS441
132+ anchor = heading .attrib ["id" ]
133+ self ._autorefs .register_anchor (page , anchor )
129134
130135 if "data-role" in heading .attrib :
131136 self ._handlers .inventory .register (
132- name = anchor , # noqa: WPS441
137+ name = anchor ,
133138 domain = handler .domain ,
134139 role = heading .attrib ["data-role" ],
135- uri = f"{ page } #{ anchor } " , # noqa: WPS441
140+ uri = f"{ page } #{ anchor } " ,
136141 )
137142
138143 parent .append (el )
@@ -187,22 +192,22 @@ def _process_block(
187192 try :
188193 data : CollectorItem = handler .collect (identifier , options )
189194 except CollectionError as exception :
190- log .error (str (exception ))
195+ log .error (str (exception )) # noqa: TRY400
191196 if PluginError is SystemExit : # When MkDocs 1.2 is sufficiently common, this can be dropped.
192- log .error (f"Error reading page '{ self ._autorefs .current_page } ':" )
197+ log .error (f"Error reading page '{ self ._autorefs .current_page } ':" ) # noqa: TRY400
193198 raise PluginError (f"Could not collect '{ identifier } '" ) from exception
194199
195200 if handler_name not in self ._updated_envs : # We haven't seen this handler before on this document.
196201 log .debug ("Updating renderer's env" )
197- handler ._update_env (self .md , self ._config ) # noqa: WPS437 (protected member OK)
202+ handler ._update_env (self .md , self ._config ) # (protected member OK)
198203 self ._updated_envs .add (handler_name )
199204
200205 log .debug ("Rendering templates" )
201206 try :
202207 rendered = handler .render (data , options )
203208 except TemplateNotFound as exc :
204209 theme_name = self ._config ["theme_name" ]
205- log .error (
210+ log .error ( # noqa: TRY400
206211 f"Template '{ exc .name } ' not found for '{ handler_name } ' handler and theme '{ theme_name } '." ,
207212 )
208213 raise
@@ -211,12 +216,12 @@ def _process_block(
211216
212217 @classmethod
213218 @functools .lru_cache (maxsize = None ) # Warn only once
214- def _warn_about_options_key (cls ):
219+ def _warn_about_options_key (cls ) -> None :
215220 log .info ("DEPRECATION: 'selection' and 'rendering' are deprecated and merged into a single 'options' YAML key" )
216221
217222
218223class _PostProcessor (Treeprocessor ):
219- def run (self , root : Element ):
224+ def run (self , root : Element ) -> None :
220225 carry_text = ""
221226 for el in reversed (root ): # Reversed mainly for the ability to mutate during iteration.
222227 if el .tag == "div" and el .get ("class" ) == "mkdocstrings" :
0 commit comments