No error when attempting to use property object as that property's type
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
- 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, mypy a.py mit dem angegebenen Beispiel auszuführen, und bestätige, dass dabei keine Ausgabe erzeugt wird, während Python den angegebenen TypeError auslöst. Verfolge, wie mypy den NamedTuple-Eigenschaftszugriff und den arithmetischen Ausdruck behandelt; abgeschlossen ist die Aufgabe, wenn mypy für diesen Fall einen Fehler bei C.a * 2 meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100