No error when attempting to use property object as that property's type
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
- Are you reporting a bug, or opening a feature request? Bug
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
from typing import NamedTuple
class C(NamedTuple):
a: int = 1
print(C.a * 2)
- What is the actual behavior/output?
mypy a.py produces no output.
- What is the behavior/output you expect?
An error at C.a * 2, as it will cause an error at runtime: TypeError: unsupported operand type(s) for *: 'property' and 'int'
- What are the versions of mypy and Python you are using?
python --version: 3.7.2
mypy --version: 0.660+dev.97d7760dca6d95806a97b02992ae88a082898a0e
Do you see the same issue after installing mypy from Git master? Yes
- What are the mypy flags you are using? (For example --strict-optional) None
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 mypy a.py con l’esempio indicato e verifica che non produca alcun output, mentre Python solleva il TypeError indicato. Traccia il modo in cui mypy gestisce l’accesso alla proprietà di NamedTuple e l’espressione aritmetica; il lavoro è completato quando mypy segnala un errore in C.a * 2 per questo caso.
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
- 45/100