Avoid type checking dependencies when errors aren't reported
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
Feature
When we're type checking code that we aren't going to report errors for (like any code in site-packages), we can improve performance by avoiding doing most of the work of type checking.
Pitch
I tried type checking mypy with an uncompiled mypy from master (19e9f2136fd46c662f1066a4894edf48173942f4) itself using this command:
mypy mypy mypyc --config-file mypy_self_check.ini --no-incremental --timing-stats timing_data.txt
The results I got using the per-file timing stats were that of the approximately 63.6 seconds spent type checking, 44.3 seconds were spent type checking modules in mypy or mypyc, and the remaining 19.3 seconds were spent in other modules.
While 19.3 seconds isn't a majority of the build time, it is still a not insignificant amount of time spent type checking dependencies, even though that work will mostly get thrown away since we don't report errors in any of those dependencies.
There are probably a couple things we can skip doing for code that doesn't have errors reported:
- Avoid semantic analysis and type checking inside functions, since that shouldn't affect what other modules see.
- Skip particularly expensive checks at module level when type checking (we can't really completely skip type checking because we probably still need to run type inference on that code, and I think we group those together).
- Avoid loading modules that are never used directly in the code being checked (currently we sometimes analyze modules that are imported directly or indirectly by another dependency module that is directly used in checked code).
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 riproducendo il problema con il comando mypy e l'output di timing-stats forniti, quindi confronta il tempo impiegato per il controllo delle dipendenze con quello impiegato per il codice i cui errori vengono segnalati. Il lavoro è completato quando il controllo non segnalato delle dipendenze viene ridotto senza modificare la diagnostica o le informazioni sui tipi richieste per il codice controllato direttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100