TypeError from sorting incompatible types isn't flagged
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
I was surprised that some code like this wasn't flagged by mypy:
[1, None].sort()
-
What is the actual behavior/output?
No error. -
What is the behavior/output you expect?
I would expect a similar warning as I get if I do1 > None
test.py:12: error: Unsupported operand types for > ("int" and "None")
-
What are the versions of mypy and Python you are using?
mypy 0.782, python 3.8.2 -
What are the mypy flags you are using? (For example --strict-optional)
follow_imports=normal
warn_redundant_casts=True
warn_unused_ignores=True
strict_optional=True
strict_equality=True
no_implicit_optional=True
disallow_untyped_defs=True
disallow_any_generics=True
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
Non viene indicato alcun file sorgente né alcun test. Inizia riproducendo i due esempi con mypy 0.782 e i flags elencati, quindi segui come viene verificato il tipo di list.sort() rispetto all’espressione di confronto. Il lavoro è completo quando i tipi di elemento incompatibili in [1, None].sort() producono una diagnosi appropriata e un test di regressione copre il comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100