python / python/mypy

Give better error message if type inference fails because of unsatisfiable upper bound

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

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

priority-1-normal topic-type-variables topic-usability
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

After #5699 in certain cases (see testWideOuterContextEmptyError) if type inference fails, mypy gives an obscure error like

Incompatible types in assignment (expression has type "List[<nothing>]", variable has type "List[str]")

This error message could be improved. Here are some ideas:

  • Record that we didn't use the outer context because of unsatisfied bound and add a note about this
  • (Probably better) If type variable with a bound is used in an invariant context and we can't infer a value, we currently infer C[<nothing>]. What if we'd instead inferred C[<bound>]?

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

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

はじめの一歩

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

調査の方向性

Issue で言及されている testWideOuterContextEmptyError ケースから始め、不変コンテキストにおける満たされていない上限に対する型推論の経路を調査してください。提案されている診断アプローチを比較し、改善されたエラーメッセージを示す回帰テストを追加してから、関連するテストスイートを実行してください。

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

評価

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

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

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