Clarification of `properly subclassable class` in NewType
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
I want to create a new type derived from ObjectId in similar way as is described in documentation for new type UserId derived from int:
from bson import ObjectId
UserId = NewType('UserId', ObjectId)
But Mypy gives Argument 2 to NewType(...) must be subclassable (got "Any").
There is written in documentation:
NewType accepts exactly two arguments. The first argument must be a string literal containing the name of the new type and must equal the name of the variable to which the new type is assigned. The second argument must be a properly subclassable class, i.e., not a type construct like Union, etc.
It is not clear what properly subclassable class means and why ObjectId is not properly subclassable class. Could please someone clarify this to me and in documentation?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンク先のNewTypeドキュメントのセクションから始め、ObjectIdを使って診断を再現してください。「適切にサブクラス化可能なクラス」が何を意味するのかを明確にし、ObjectIdがAnyとして報告される理由を説明してください。そのうえで、改訂された文言が例に対応し、既存のNewTypeに関するガイダンスを維持していることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100