Skip to content

Commit

Permalink
prepare for handling PEP 649
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz committed Jun 9, 2024
1 parent 1352d08 commit 7197e17
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Lib/symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL,
DEF_PARAM, DEF_TYPE_PARAM, DEF_IMPORT, DEF_BOUND, DEF_ANNOT,
SCOPE_OFF, SCOPE_MASK,
FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL
FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL,
)

import weakref
Expand Down Expand Up @@ -231,13 +231,14 @@ def is_local_symbol(ident):
if is_local_symbol(st.name):
if st.type == _symtable.TYPE_TYPE_PARAM:
# Current 'st' is an annotation scope with one or
# more children (we expect only one, but we might
# have more in the future). In particular, we need
# to find the corresponding inner function, class or
# type alias.
st = next((c for c in st.children if c.name == st.name), None)
# if 'st' is None, then the annotation scopes are broken
assert st is not None, 'annotation scopes are broken'
# more children and we expect at most one to be of
# type TYPE_FUNCTION and with the same identifier.
for st_c in st.children:
if st_c.name == st.name and st_c.type == _symtable.TYPE_FUNCTION:
d[st.name] = 1
break
else:
continue

# only select function-like symbols
if st.type == _symtable.TYPE_FUNCTION:
Expand Down

0 comments on commit 7197e17

Please sign in to comment.