1
1
from __future__ import annotations
2
2
3
- from typing import TYPE_CHECKING , Any , Callable
3
+ from typing import TYPE_CHECKING , Any , Callable , ValuesView
4
4
5
5
from sphinx .domains .c ._ast import (
6
6
ASTDeclaration ,
@@ -118,8 +118,8 @@ def __init__(
118
118
self ._add_function_params ()
119
119
120
120
@property
121
- def _children (self ) -> Sequence [Symbol ]:
122
- return list ( self ._childrenByName .values () )
121
+ def _children (self ) -> ValuesView [Symbol ]:
122
+ return self ._childrenByName .values ()
123
123
124
124
def _add_child (self , child : Symbol ) -> None :
125
125
name = child .ident .name
@@ -135,7 +135,7 @@ def _remove_child(self, child: Symbol) -> None:
135
135
self ._childrenByName .pop (name )
136
136
siblings = self ._childrenByDocname .get (child .docname , {})
137
137
if name in siblings :
138
- siblings . pop ( name )
138
+ del siblings [ name ]
139
139
if child .ident .is_anon () and child in self ._anonChildren :
140
140
self ._anonChildren .remove (child )
141
141
@@ -188,7 +188,9 @@ def clear_doc(self, docname: str) -> None:
188
188
for child in self ._children :
189
189
child .clear_doc (docname )
190
190
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 ():
192
194
sChild .declaration = None
193
195
sChild .docname = None
194
196
sChild .line = None
@@ -198,9 +200,7 @@ def clear_doc(self, docname: str) -> None:
198
200
sChild .siblingBelow .siblingAbove = sChild .siblingAbove
199
201
sChild .siblingAbove = None
200
202
sChild .siblingBelow = None
201
-
202
203
self ._remove_child (sChild )
203
- del self ._childrenByDocname [docname ]
204
204
205
205
def get_all_symbols (self ) -> Iterator [Symbol ]:
206
206
yield self
0 commit comments