Many classes should be decorated as `@final`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
While working on several mypy plugins I had often step on the fact you cannot subclass any of the mypy classes, because they are compiled with mypyc. It caused runtime TypeError in the plugin's code.
But, when I was trying to run mypy on the plugin's code - it was fine, no error was shown. Because type are not @final and mypy is not able to understand that this is a problem.
So, I propose to add explicit @final annotations to almost all types, exception:
- Types with
allow_interpreted_subclasses - Types that are subclassed inside
mypyitself:Node,Expression,TypeQuery, etc
One more strong point to making this change is that many classes are not "designed" to be subclassed.
So, this should not be a problem.
Related https://github.com/python/mypy/pull/10125
Related https://github.com/python/mypy/pull/9602
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
L’issue non indica file, test o punti di ingresso. Inizia individuando le definizioni delle classi di mypy e identificando le eccezioni indicate, inclusi i tipi con allow_interpreted_subclasses e le classi derivate all’interno di mypy. Il lavoro è completato quando le classi applicabili sono annotate con @final e il codice del plugin viene verificato di conseguenza.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100