mypy doesnt use unitest.TestCase.assertIsInstance checks for type narrowing
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Merge medio
- 1g 18h
- PR unite (30g)
- 54
Descrizione
Apologies if i'm using the wrong words to describe what i'm trying to recommend/request.
Feature
At the moment, mypy recommends type narrowing using asserts. For example, if something is Optional[None], add assert something is not None to help mypy type check the statements that follow the assert.
In tests, instead of adding an additional assert, can mypy use a unittest.TestCase.assertIsInstance check?
Pitch
Most unittest-based tests already make use of the assertIsInstance check so we can prevent the need to add an additional assert or the need to convert the assertIsInstance into a assert isinstance(something) is sometype.
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
Nell'issue non sono indicati file, test o punti di ingresso. Inizia tracciando la gestione esistente di mypy di unittest.TestCase.assertIsInstance e la relativa logica di restringimento dei tipi, quindi individua l'area appropriata per i test di regressione. Il lavoro è completo quando i controlli assertIsInstance supportati restringono i tipi senza un assert aggiuntivo e sono coperti da test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100