symtable entries should expose the scope attributes computed by the analysis
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Feature or enhancement
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.
Linked PRs
- gh-153850
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まずリンクされた PR gh-153850 を確認し、次に issue がこれらの属性のソースとして特定している Python/symtable.c のスコープ分析を読んでください。要求された値がシンボルテーブルエントリの読み取り専用属性として公開されていること、およびリンクされた PR が記載されたケースをカバーしていることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100