Feature request for something like --disallow-any-attrs
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Disclaimer: mypy newbie here, so I might just be missing something. See also my StackOverflow question for my motivation to request this feature.
Basically I couldn't find a way for mypy to require type annotations on class attributes as in the following (incomplete) example with ignore_missing_imports turned on for sqlalchemy.*.
from sqlalchemy import Column, Integer
class Foo(Base):
oid = Column(Integer, primary_key=True)
I want code using my library (ORM definitions) to know what types they can expect. So I need mypy to make sure that oid is type annotated (e.g. oid: int = ...).
disallow_any_unimported does not seem to apply for oid. I also tried disallow_any_expr but this seems far to broad and has side-effects like causing mypy to complain about the use of Integer (Even with disallow_any_unimported = False).
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、SQLAlchemy Foo の例を動機となるケースとして、クラス属性に要求されている動作を既存の disallow_any_unimported オプションおよび disallow_any_expr オプションと比較します。次に、disallow_any_expr について説明されている、より広範な副作用を別のオプションでどのように回避すべきかを判断し、その後、注釈付き属性と注釈なし属性が意図した診断を生成することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100