11from __future__ import annotations
22
3- from typing import TYPE_CHECKING , Any , Callable
3+ from typing import TYPE_CHECKING , Any , Callable , ValuesView
44
55from sphinx .domains .c ._ast import (
66 ASTDeclaration ,
@@ -117,8 +117,8 @@ def __init__(
117117 self ._add_function_params ()
118118
119119 @property
120- def _children (self ) -> Sequence [Symbol ]:
121- return list ( self ._childrenByName .values () )
120+ def _children (self ) -> ValuesView [Symbol ]:
121+ return self ._childrenByName .values ()
122122
123123 def _add_child (self , child : Symbol ) -> None :
124124 name = child .ident .name
@@ -134,7 +134,7 @@ def _remove_child(self, child: Symbol) -> None:
134134 self ._childrenByName .pop (name )
135135 siblings = self ._childrenByDocname .get (child .docname , {})
136136 if name in siblings :
137- siblings . pop ( name )
137+ del siblings [ name ]
138138 if child .ident .is_anon () and child in self ._anonChildren :
139139 self ._anonChildren .remove (child )
140140
@@ -187,7 +187,9 @@ def clear_doc(self, docname: str) -> None:
187187 for child in self ._children :
188188 child .clear_doc (docname )
189189 return
190- for sChild in self ._childrenByDocname [docname ].values ():
190+
191+ children : dict [str , Symbol ] = self ._childrenByDocname .pop (docname )
192+ for sChild in children .values ():
191193 sChild .declaration = None
192194 sChild .docname = None
193195 sChild .line = None
@@ -197,9 +199,7 @@ def clear_doc(self, docname: str) -> None:
197199 sChild .siblingBelow .siblingAbove = sChild .siblingAbove
198200 sChild .siblingAbove = None
199201 sChild .siblingBelow = None
200-
201202 self ._remove_child (sChild )
202- del self ._childrenByDocname [docname ]
203203
204204 def get_all_symbols (self ) -> Iterator [Symbol ]:
205205 yield self
0 commit comments