python / python/mypy

Do not check LSP compatibility of `plugin_generated` nodes

Aperta
#20,008 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature topic-plugins
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Feature

When plugins add some methods or variables, it should be their responsibility to decide whether the override should be checked for LSP compat.

Pitch

This is already hitting the pydantic plugin, for example, resulting in some very weird workaround involving adding an unresolved classmethod decorator that shouldn't be there at all.

In many cases a plugin-generated method has narrower signature than the base class definition, and there is no way to make it compatible with super definition (which can't be removed either to support other typecheckers). We still want a plugin to be able to define such a signature without introducing noise, assuming that the plugin author is already aware that such behavior violates LSP.

It should become easy to run LSP checks manually from plugin code. Checker API should be extended to include the necessary methods, or we'll see increased use of mypy internals or unexpectedly omitting LSP checks altogether because they are too tricky to implement correctly.

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 tracciando i controlli di compatibilità LSP di mypy e il modo in cui vengono rappresentati i nodi generati dai plugin. Definisci l'API del checker necessaria affinché i plugin possano eseguire manualmente questi controlli e aggiungi una copertura che dimostri che gli override generati dai plugin evitano le diagnosi LSP automatiche, mentre gli override ordinari continuano a essere verificati.

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
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.