Cannot determine type of "userlist"
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo python3 -m mypy foo.py bar.py sull'esempio fornito di importazioni cicliche e confronta l'errore userlist con il comportamento previsto. Segui come mypy analizza le definizioni di Foo, ServerView e ChannelView in foo.py e bar.py; il lavoro è completato quando l'esempio non produce più l'errore confuso Cannot determine type of "userlist" oppure segnala una diagnosi più chiara.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100