Feature request: option that prohibits any use of type:ignore, and other type-checking-suppression mechanisms
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
Feature
PEP 484 lists several ways to ignore type checking https://peps.python.org/pep-0484/#compatibility-with-other-uses-of-function-annotations:
# type: ignorecomment- a
@no_type_checkdecorator on a class or function - a custom class or function decorator marked with
@no_type_check_decorator
I would like an option that disallows all of these methods, eg --disallow-type-ignores
Pitch
My basic idea here is that I want to actually enforce typing and have it completely statically verified, when possible. If that isn't happening, I'd like to know! And possibly refactor my code to remove the ignores. — I would like mypy to be able to tell me whether or not my types are completely automatically enforced, without any ignores, if I use the right flag. This seems like an ergonomic way to enable that. (There are probably other ways to cheat the python type checker that could also be ruled out, with other flags.)
While useful, these type-checker-ignore features get around static type safety without ensuring dynamic type correctness, which is not ideal. Sometimes you have to use them—you know how it is—but it's not ideal. That means, in my opinion, it would be great to have a option for disallowing their use, to ensure mandatory type-safety in codebases where these workarounds are not in fact needed.
I don't think it would make sense to turn this option on by default, nor in strict mode. The ecosystem of typing just isn't thorough and unimpingable enough, in my experience. It could maybe make sense to go in some hypothetical ultrastrict mode, but I don't think most strict mode users would benefit from this option being turned on.
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
Esamina i meccanismi di soppressione di PEP 484 elencati nell’issue e individua dove mypy gestisce le opzioni della riga di comando e la soppressione del controllo dei tipi. Definisci l’ambito e il comportamento dell’opzione per type: ignore, @no_type_check e @no_type_check_decorator, quindi aggiungi una copertura che dimostri che ogni meccanismo viene rifiutato quando l’opzione è abilitata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100