python / python/mypy

Add single configuration option to retain various old behaviors

Aperta
#5,403 5 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature needs discussion priority-1-normal
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo la proposta e le issue correlate #5392 e #5401. Esamina come mypy gestisce attualmente le opzioni di configurazione e i comportamenti di controllo dei tipi interessati. Il lavoro sarà considerato completato quando sarà disponibile un design concordato per un'unica opzione di compatibilità separata da virgole, inclusi il suo ambito e i comportamenti legacy supportati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
compilers, devtools
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.