PEP696 + PEP749: Defer evaluation of defaults when parametrizing
オープン
まだ誰も着手していません。
stdlib
topic-typing
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
With PEP 696 + PEP 749, the following works just fine:
class Scalar[CompatT, TruthT = BoolScalar]: ...
class BoolScalar(Scalar): ...
class IntScalar(Scalar[int]): ... # OK ✅️
However, if we switch around the order of definition, the code breaks:
class Scalar[CompatT, TruthT = BoolScalar]: ...
class IntScalar(Scalar[int]): ... # ❌️ NameError: name 'BoolScalar' is not defined
class BoolScalar(Scalar): ...
I guess since the default gets evaluated here. Not sure whether this is a bug or feature request, but it would be nice if the evaluation of the default could be deferred in is case as well.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-152208
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue にある2つのクラス定義の例を CPython 3.14 で実行し、動作を比較します。リンクされている PEP 696 と PEP 749 の議論を読み、リンクされている PR gh-152208 を確認します。前方定義の例で NameError が発生しなくなり、既存の例が引き続き動作すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100