Spurious "progress" during final iteration
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
I discovered this anomaly while debugging mypy in a different situation #12458.
In the final iteration of semanal_main.process_top_levels, I found that self.progress was being set = True by semanal.add_symbol_table_node.
As it turns out, this setting is ignored in process_top_levels as it's the final iteration. However, the local variable final_iteration becomes False, and that could cause problems in some future version of the code.
I suggest in semanal.add_symbol_table_node, you replace
self.progress = True
with
if not self.final_iteration:
self.progress = True
Now, regarding why a new symbol table node is being added at this late stage, it appears to me to be correct.
What's being added to module X is a dummy definition for a symbol that could not be imported from another module Y because (1) that symbol is undefined in Y or (2) X imports * from Y and that symbol was just added to Y while analyzing Y.
It appears that all possible imported names will get defined, because the SCC ordering guarantees that Y is analyzed before X in situation (2). That's assuming that X and Y are not in a from ... import * cycle.
The cyclic case should be reported as an error, in my opinion. I am filing a separate issue about that.
The dummy definition is a symbol table node with a FakeInfo object, which will get interpreted as Any in later type analysis or error reports. Are you sure you want a FakeInfo? This might lead to some bugs in a future version of the code, and you might want to create a symbol table node with type info for the real Any type.
- Mypy version used: 0.931
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
Cerca semanal_main.process_top_levels e semanal.add_symbol_table_node, quindi leggi come interagiscono final_iteration e progress durante il passaggio finale. Il lavoro è completato quando progress non viene impostato durante quel passaggio, mentre il comportamento della tabella dei simboli fittizia rimane corretto; verifica inoltre se la segnalazione relativa a FakeInfo richiede una modifica separata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100