Unexpected "incompatible type" error when chaining bytes(filter())
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
Bug Report
Mypy reports a strange type error when calling bytes(filter(...)) like below.
Write the following contents to a file and run mypy:
f = filter(lambda ch: chr(ch), b"hello")
bytes(f)
bytes(filter(lambda ch: chr(ch), b"hello"))
Mypy reports an error on line 4 but not on lines 1/2, despite the two sections being functionally identical. The expected result is that there should be no errors in this code example.
> mypy /tmp/test.py
/tmp/test.py:4: error: Argument 1 to "chr" has incompatible type "SupportsIndex"; expected "int"
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: mypy 0.931
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: python 3.10.2
- Operating system and version: Arch linux and windows 10
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
Riproduci il report scrivendo gli esempi mostrati in /tmp/test.py ed eseguendo mypy senza flags. Confronta i tipi inferiti per le forme separata e concatenata, quindi traccia il percorso rilevante del controllo dei tipi; il lavoro è completato quando entrambe le forme non producono errori e la regressione è coperta da un test appropriato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100