Add single configuration option to retain various old behaviors
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Every once in a while we change something in mypy that breaks backward compatibility, and this can make it hard for owners of large codebases to migrate to a new mypy version. A related issue is that some changes that we'd like to make would cause so much work for existing users that we decide to postpone the change indefinitely (see #5392 as an example).
What if we'd adopt a policy of retaining the old behaviors through a configuration option, whenever there is a lot of expected breakage? This way existing users could just continue to use the old behavior without having to migrate their code, while new users would automatically get the new (and improved, I'd hope) behavior.
A potential drawback would be the introduction of many additional options for legacy behaviors that are only of interest to a small subset of users. My solution to this is to enable all of the behaviors with a single option.
Let's use #5392 as an example. The change would cause some if/else expression to return a union type instead of a join. We could enable the old behavior through --backward-compat if-else (the option name needs more thought). The value of the option would be a comma-separated list of legacy behaviors.
Another candidate for this feature is #5401.
Pros:
- Migration to new mypy versions will be easier for users with lots of code.
- Breaking changes are easier to justify, since we can provide a fallback for existing users.
- Backward compatibility features are behind a single option which can be easily ignored by users that don't care about it.
- If the compatibility options are per-module, migration to new semantics can be performed gradually.
Cons:
- Some users may be unaware of the option and be reluctant to upgrade to new mypy versions because of the migration work they believe to be necessary.
- Supporting multiple additional options may decrease maintainability of mypy and result in bugs and weird corner cases.
- We may never be able to deprecate some old behaviors.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza leyendo la propuesta y las issues relacionadas #5392 y #5401. Revisa cómo gestiona actualmente mypy las opciones de configuración y los comportamientos de comprobación de tipos afectados. Se considerará terminado cuando exista un diseño acordado para una única opción de compatibilidad separada por comas, incluido su alcance y los comportamientos heredados que admite.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- compilers, devtools
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100