python / python/mypy

Add single configuration option to retain various old behaviors

Ouverte
#5,403 5 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

feature needs discussion priority-1-normal
Langage dominant
Python
Étoiles
20.6k
Forks
3.3k
Métriques de merge des PR
Métriques de PR en attente

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par lire la proposition et les issues associées #5392 et #5401. Examinez la manière dont mypy gère actuellement les options de configuration et les comportements de vérification de types concernés. La tâche sera considérée comme terminée lorsqu'une conception approuvée d'une unique option de compatibilité séparée par des virgules aura été définie, y compris sa portée et les anciens comportements qu'elle prend en charge.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
compilers, devtools
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.