Generic method returning nested class
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
-
Are you reporting a bug, or opening a feature request? bug
-
Please insert below the code you are checking with mypy.
from typing import Generic, TypeVar T = TypeVar('T', bound='Base') class Base: class Inner: ... class A(Base): class Inner: ... class Foo(Generic[T]): def func(self) -> T.Inner: ... foo = Foo[A]() reveal_type(foo.func()) -
What is the actual behavior/output?
main.pyi:15: error: Revealed type is 'main.A*' -
What is the behavior/output you expect?
main.pyi:15: error: Revealed type is 'main.A.Inner*'If the analyzer is not sophisticated enough to figure this out yet, it should raise an error/warn and turn into
<nothing>rather than becoming the wrong type. -
What are the versions of mypy and Python you are using? mypy v0.701 + CPython v3.7.1
Do you see the same issue after installing mypy from Git master? yes, same results with 0.710+dev.bb7dbd5afd84656a62311e5f69a1cef6d06466bc
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
main.pyi の再現コードから始め、特に Foo.func のジェネリックな戻り値アノテーションと、15 行目の reveal_type 呼び出しを確認してください。type checker が Foo[A] に対して T.Inner をどのように解決するかを追跡してください。A ではなく A.Inner を報告するか、エラーを出力して型を生成しなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100