ctypes.Structure and Iterable
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
For some reason ctypes.Structure instances pass mypy's isinstance checks although mypy also claims that they are not iterable.
For example, consider the following code:
from ctypes import Structure
from typing import Iterable
class S(Structure):
pass
s = S()
if isinstance(s, Iterable):
for _ in s:
pass
mypy gives the following error:
test.py:13: error: "S" has no attribute "__iter__" (not iterable)
Found 1 error in 1 file (checked 1 source file)
replacing it with iter(s) make mypy happy again.
Your Environment
- Mypy version used: mypy 0.790
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: Python 3.8.6
- Operating system and version: Linux ubuntu 5.10.0 #17 SMP Mon Dec 14 10:04:17 IST 2020 x86_64 x86_64 x86_64 GNU/Linux
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
Inizia eseguendo il riproduttore Python segnalato con mypy e confronta il ramo isinstance(s, Iterable) con la chiamata iter(s). Traccia quindi il comportamento rilevante del controllo dei tipi per ctypes.Structure e Iterable, poi aggiungi un test di regressione che mostri la coerenza attesa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100