Add decorator to mark class as concrete / instantiable
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 302
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 8
説明
We have the @final decorator to mark a class as final, so that it cannot be subclassed. Typecheckers can then cue off of this to raise an error when there are unimplemented abstract methods (e.g. the Ty abstract-method-in-final-class rule).
Similarly, Pyright and Ty can flag errors when other code instantiates a class that has abstract methods.
However, I would find it very useful to be able to mark a class as concrete: it isn't final (someone might subclass it), but it is intended to be instantiable. This would allow the type checker to raise abstract method errors at the point of class definition, rather than elsewhere in the code where the class is instantiated. For classes that are instantiated directly, the error location isn't a huge problem; for classes that are primarily instantiated indirectly, however, it there is no guarantee that the code will include a direct instantiation of the class to raise an error.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、既存の @final デコレーターと、Pyright および Ty について説明されている抽象メソッドの動作を併せて提案を確認します。具象クラスデコレーターの意図する型チェックのセマンティクスを定義し、抽象メソッドを持つクラスについて、クラス定義時にエラーが報告されることを確認します。ただし、クラスを final にはしません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100