Cannot determine type of "userlist"
オープン
まだ誰も着手していません。
bug
topic-import-cycles
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
Unexpected error Cannot determine type of "userlist". Needs a cyclic import to happen.
To Reproduce
foo.py
import bar
class Foo:
def __init__(self) -> None:
self.view_selector = object()
bar.py
from foo import Foo
class ServerView:
def __init__(self) -> None:
print(ChannelView().userlist)
self.view_id = str(Foo().view_selector)
class ChannelView:
def __init__(self) -> None:
print(ServerView().view_id)
self.userlist = object()
Expected Behavior
no error, or an error that does not confusingly go away when I delete a seemingly unrelated line of code
Actual Behavior
$ python3 -m mypy foo.py bar.py
bar.py:5: error: Cannot determine type of "userlist"
Found 1 error in 1 file (checked 2 source files)
Your Environment
- Mypy version used: master (053a1beb94ee4e5b3260725594315d1b6776e42f)
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: doesn't matter, why do you ask?
- Operating system and version: is a weird question to ask. I am tired of answering this question. But I guess it could be useful in some other issue.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された循環インポートの例に対して python3 -m mypy foo.py bar.py を実行し、userlist エラーを期待される動作と比較します。mypy が foo.py と bar.py の Foo、ServerView、ChannelView の定義をどのように解析するかを追跡します。完了の条件は、例で紛らわしい Cannot determine type of "userlist" エラーが発生しなくなるか、より明確な診断が報告されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100