Conditional annotations are always included in `STRING` annotations
オープン
まだ誰も着手していません。
3.14
3.15
3.16
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
If an annotation is excluded via a conditional block it is correctly excluded in VALUE and FORWARDREF annotations but is incorrectly included under STRING annotations.
from annotationlib import get_annotations, Format
class Example:
a: int
if False:
b: str
print(get_annotations(Example))
print(get_annotations(Example, format=Format.STRING))
{'a': <class 'int'>}
{'a': 'int', 'b': 'str'}
'b' should not be included in string annotations here.
CPython versions tested on:
3.14, 3.15, CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-156516
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず get_annotations と Format.STRING を使って例を再現し、その後 annotationlib の実装と関連するテストを調べます。STRING の結果に b などの条件付きアノテーションが含まれず、VALUE と FORWARDREF の動作と一致し、回帰が成功するテストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100