python / python/mypy

New setting "user_builtins_name": Ignore specific "name-defined" errors

Abierto
#18,932 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

feature
Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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:

  1. Analyzer all the code to add dynamically the "user builtins name"
  2. 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza revisando el issue relacionado #7931 y el manejo de configuración existente de mypy para los diagnósticos name-defined. Rastrea dónde se producen estos errores y cómo se prueban las configuraciones; se considera terminado cuando una configuración builtins-name controlada por el usuario suprima únicamente los errores especificados y esto esté cubierto por pruebas y documentación adecuadas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
devtools
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.