python / python/mypy

Better message if override violates Liskov substitution principle

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

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

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

説明

Some users don't understand why mypy complains about incompatible overrides. We could add an extra note in cases where the argument type is narrower in an override or the return type is wider (or all incompatible overrides). The note could mention Liskov substitution principle and add a link to mypy documentation (add a new section to https://mypy.readthedocs.io/en/latest/common_issues.html perhaps). We can also mention that # type: ignore[override] can be used to silence this error.

#7992 is an example where this came up, but several users have been confused about this.

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

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

はじめの一歩

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

調査の方向性

まず、mypy の incompatible-override 診断の処理箇所を特定し、issue でリンクされている一般的な問題のドキュメントを確認します。動機となった例については issue #7992 を確認してください。関連する override のケースで Liskov substitution principle を説明し、ドキュメントへのリンクを含め、override の type-ignore オプションに言及し、そのメッセージをカバーするテストがあることが完了条件です。

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

評価

技術スタック
python
領域
documentation, tooling
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

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

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