Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
prepare for handling PEP 649
  • Loading branch information
picnixz committed Jun 9, 2024
commit 62d2d6d33ef2ddac81116d2aa2a00c84dac28a31
26 changes: 12 additions & 14 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 @@ -229,19 +229,17 @@ def is_local_symbol(ident):
for st in self._table.children:
# pick the function-like symbols that are local identifiers
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'

# only select function-like symbols
if st.type == _symtable.TYPE_FUNCTION:
d[st.name] = 1
match st.type:
case _symtable.TYPE_FUNCTION:
d[st.name] = 1
case _symtable.TYPE_TYPE_PARAM:
# Get the function-def block in the annotation
# scope 'st' with the same identifier, if any.
scope_name = st.name
for c in st.children:
if c.name == scope_name and c.type == _symtable.TYPE_FUNCTION:
d[st.name] = 1
break
self.__methods = tuple(d)
return self.__methods

Expand Down