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 ,
@@ -118,8 +118,8 @@ def __init__(
118118 self ._add_function_params ()
119119
120120 @property
121- def _children (self ) -> Sequence [Symbol ]:
122- return list ( self ._childrenByName .values () )
121+ def _children (self ) -> ValuesView [Symbol ]:
122+ return self ._childrenByName .values ()
123123
124124 def _add_child (self , child : Symbol ) -> None :
125125 name = child .ident .name
@@ -135,7 +135,7 @@ def _remove_child(self, child: Symbol) -> None:
135135 self ._childrenByName .pop (name )
136136 siblings = self ._childrenByDocname .get (child .docname , {})
137137 if name in siblings :
138- siblings . pop ( name )
138+ del siblings [ name ]
139139 if child .ident .is_anon () and child in self ._anonChildren :
140140 self ._anonChildren .remove (child )
141141
@@ -188,7 +188,9 @@ def clear_doc(self, docname: str) -> None:
188188 for child in self ._children :
189189 child .clear_doc (docname )
190190 return
191- for sChild in self ._childrenByDocname [docname ].values ():
191+
192+ children : dict [str , Symbol ] = self ._childrenByDocname .pop (docname )
193+ for sChild in children .values ():
192194 sChild .declaration = None
193195 sChild .docname = None
194196 sChild .line = None
@@ -198,9 +200,7 @@ def clear_doc(self, docname: str) -> None:
198200 sChild .siblingBelow .siblingAbove = sChild .siblingAbove
199201 sChild .siblingAbove = None
200202 sChild .siblingBelow = None
201-
202203 self ._remove_child (sChild )
203- del self ._childrenByDocname [docname ]
204204
205205 def get_all_symbols (self ) -> Iterator [Symbol ]:
206206 yield self
0 commit comments