|
6 | 6 | DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL,
|
7 | 7 | DEF_PARAM, DEF_TYPE_PARAM, DEF_IMPORT, DEF_BOUND, DEF_ANNOT,
|
8 | 8 | SCOPE_OFF, SCOPE_MASK,
|
9 |
| - FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL |
| 9 | + FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL, |
10 | 10 | )
|
11 | 11 |
|
12 | 12 | import weakref
|
@@ -231,13 +231,14 @@ def is_local_symbol(ident):
|
231 | 231 | if is_local_symbol(st.name):
|
232 | 232 | if st.type == _symtable.TYPE_TYPE_PARAM:
|
233 | 233 | # Current 'st' is an annotation scope with one or
|
234 |
| - # more children (we expect only one, but we might |
235 |
| - # have more in the future). In particular, we need |
236 |
| - # to find the corresponding inner function, class or |
237 |
| - # type alias. |
238 |
| - st = next((c for c in st.children if c.name == st.name), None) |
239 |
| - # if 'st' is None, then the annotation scopes are broken |
240 |
| - assert st is not None, 'annotation scopes are broken' |
| 234 | + # more children and we expect at most one to be of |
| 235 | + # type TYPE_FUNCTION and with the same identifier. |
| 236 | + for st_c in st.children: |
| 237 | + if st_c.name == st.name and st_c.type == _symtable.TYPE_FUNCTION: |
| 238 | + d[st.name] = 1 |
| 239 | + break |
| 240 | + else: |
| 241 | + continue |
241 | 242 |
|
242 | 243 | # only select function-like symbols
|
243 | 244 | if st.type == _symtable.TYPE_FUNCTION:
|
|
0 commit comments