Warn if instance atribute is defined outside of __init__
オープン
まだ誰も着手していません。
feature
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Feature
(Optionally?) generate error if the instance attribute is defined outside of __init__
Pitch
Mypy does not generate any errors for the code below:
class Tst:
def __init__(self) -> None:
...
def create_field(self) -> None:
self.abc = 1 # Please, generate error here
def print_field(self) -> None:
print(self.abc) # And, optionally here...
def main() -> None:
tst = Tst()
tst.print_field()
if __name__ == '__main__':
main()
which fails with run time error, caused by the absence of the abc attribute definition in the __init__ method.
Additionaly:
PyCharm and pylint generate error in the line 6.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue では、実装ファイル、テスト、エントリポイントが指定されていません。提供された Python の例から始めて、mypy が現在インスタンス属性をどのように扱っているかを確認してください。init 外での代入に対する診断と、print_field のような読み取りを含めるかどうかについて合意し、要求された動作をテストでカバーできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100