New setting "user_builtins_name": Ignore specific "name-defined" errors
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
Adding a setting "user_builtins_name", or "builtins", that is a array of strings for which the error [name-defined] is ignored.
Pitch
It is possible to extend the list of builtins function, which can be very useful in some projects as we no longer need to import this function if it's used extensively in the rest of the project.
Example:
builtins.__dict__['prints'] = prints = PrefixedPrint()
builtins.__dict__['_'] = localization.gettext
Sadly, mypy don't support such exotic things. There is two solution:
- Analyzer all the code to add dynamically the "user builtins name"
- Add a user-controlled setting to globally ignore specific "name-defined" errors
The first would be the best, but also the harder to implement. The second would be easier to implement, but some ignored 'name-defined' error could be legitimate depending on the import and call stack. But since the very exotic and niche feature, the risks are low and we can assume that the user know what he do when he use this settings.
The use of a setting name that contain the word 'builtins' allows to explicitly specify the user case of such setting (when a generic "ignore_name_defined" could be misinterpreted and so misused)
Related Issues
#7931
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 esaminando l’issue correlata #7931 e la gestione della configurazione esistente di mypy per le diagnosi name-defined. Traccia dove vengono prodotti questi errori e come vengono testate le impostazioni; il lavoro è completato quando un’impostazione builtins-name controllata dall’utente sopprime solo gli errori specificati e ciò è coperto da test e documentazione appropriati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100