Add `--warn-needless-override` option to `stubtest`

オープン
#13,321 コメント 16 件 リアクション 2 件 担当者 1 名 GitHub で見る

@sobolevn がすでに取り組んでいます。

2022年8月4日 から。

評価

この issue はまだ評価されていません。

説明

feature topic-stubtest

Feature

Imagine this file with implementation:

class A:
   def do_some(self) -> None:
       print('A')

class B(A):
   def do_some(self) -> None:
       print('B')

Auto-stub creators will create a stub like:

class A:
   def do_some(self) -> None: ...

class B(A):
   def do_some(self) -> None: ...

Which technically is right, but not quite.
Since do_some has the same signature in both A and B (only runtime implementation is different), we don't actually need it to be duplicated. We should ideally want just:

class A:
   def do_some(self) -> None: ...

class B(A): ...

Because we always want minimal correct stubs.
But, right now we only do this by hand.

Pitch

I propose adding --warn-needless-override options (with whatever name) that can warn us about needless overrides of parent methods in child classes.

I will send a PR with the initial imlementation.

主要言語
Python
スター
20.6k
フォーク
3.3k
平均マージ
1日 18時間
マージ済み PR(30日)
54

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

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

はじめの一歩

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

python/mypy のほかの issue

python/mypy の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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