<nothing> object is not iterable

Aperta
#4,330 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
compilers

Direzione di ricerca

Start by reproducing the example from nothingiterable.py and compare the diagnostic for the empty-list dictionary comprehension with the described vals or [] case. Trace how mypy infers the comprehension's element types and define done as handling an empty list literal without reporting the spurious ' object is not iterable' error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

This code:

d = {k: v for k, v in []}

gives

nothingiterable.py:1: error: '<nothing>' object is not iterable

(The real code this was derived from had vals or [], not just [], and mypy had concluded that vals was of type None, for unrelated bogus reasons).

I realize mypy doesn't know the type of list elements for an empty list, but it seems like in the case of an empty list literal it would be possible to realize that it doesn't matter, and the resulting type of d could be an uninhabited dictionary?

Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 18h
PR unite (30g)
54

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.