New setting "user_builtins_name": Ignore specific "name-defined" errors
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Durchsicht des zugehörigen Issues #7931 und der vorhandenen Konfigurationsbehandlung von mypy für name-defined-Diagnosen. Verfolge, wo diese Fehler erzeugt werden und wie Einstellungen getestet werden; abgeschlossen ist die Aufgabe, wenn eine vom Benutzer steuerbare builtins-name-Einstellung nur die angegebenen Fehler unterdrückt und dies durch geeignete Tests und Dokumentation abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100