You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
symtable entries should expose the scope attributes computed by the analysis #153849
The symbol table analysis computes a number of per-scope attributes that the compiler relies on, but does not expose them. I propose to add them as read-only attributes of the symbol table entries: is_generator, is_coroutine, has_annotations, has_conditional_annotations, needs_class_closure, needs_classdict, can_see_class_scope and annotation_block.
>>> import _symtable
>>> top = _symtable.symtable("async def f(): yield", "<string>", "exec")
>>> f =next(c for c in top.children if c.name =="f")
>>> f.is_generator, f.is_coroutine
(True, True)
A consumer currently has to re-derive these by walking the AST and replicating the exact rules of Python/symtable.c, which can change between versions. Trivially derivable attributes (like whether a function has a *args parameter or a docstring) are left out, but can be added later.
Activity