Constrained TypeVars with Any default
オープン
まだ誰も着手していません。
bug
topic-type-variables
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
In python/typeshed#13683 I'm trying to change a type var to the following:
_I = TypeVar("_I", int, bytes, float, bool, default=Any) # possibly memoryview types
Unfortunately, mypy complains: error: TypeVar default must be one of the constraint types [misc]. While this is of course generally sound advice, a default of Any should always be permissible, as this allows memoryview to stand for any possible memoryview type. Without it, users are forced to write memoryview[Any] in every instance, which is unreasonable.
Your Environment
- Mypy version used: 1.18.2
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mypy 1.18.2 を使って、報告された TypeVar 宣言と「TypeVar default must be one of the constraint types」エラーを再現してください。まず、制約付き TypeVar のデフォルト値に対する検証箇所を特定します。このケースで Any のデフォルト値が受け入れられ、他のデフォルト値のチェックを弱めない状態になれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100