python / python/cpython

Merge 'types.UnionType' with `typing._UnionGenericAlias`, not `typing.Union`

オープン
#137,065 コメント 21 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.14 3.15 topic-typing type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

I think #105499 was a mistake. types.UnionType was intentionally named so to avoid confusion with typing.Union (see #88895). types.UnionType should not be subscriptable because it is not generic type (and if it was a generic type, subscription would have different semantic than for typing.Union). types.UnionType corresponds to typing._UnionGenericAlias, not typing.Union (see https://github.com/python/cpython/issues/89581#issuecomment-1093932536).

So we should restore typing.Union, make typing._UnionGenericAlias an alias of types.UnionType, and make types.UnionType non-subscriptable again.

Linked PRs
  • gh-137069
  • gh-138967

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず issue から参照されている #105499、#88895、#89581 を読み、次に gh-137069 と gh-138967 にリンクされている作業を調べます。types.UnionType、typing.Union、typing._UnionGenericAlias の関係を追跡します。完了とは、意図された aliasing と subscript 不可の動作が復元され、関連するテストが通ることを意味します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。