Type hints and a function returning property
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
I have a function that works correctly.
This function uses a string as an argument and return a property.
But when I add type hints that argument is a string and return is a property, mypy says:
main.py:4: error: "property" used with a non-method
main.py:14: error: Incompatible return value type (got overloaded function, expected "property")'
Found 2 errors in 1 file (checked 1 source file)
To Reproduce
A reproducible playground link
Expected Behavior
I expect that the function has to pass mypy test without errors.
Actual Behavior
main.py:4: error: "property" used with a non-method
main.py:14: error: Incompatible return value type (got overloaded function, expected "property")'
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.981
- Mypy command-line flags: no flags
- Mypy configuration options from
mypy.ini(and other config files): default config - Python version used: 3.10
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 mit der verlinkten Reproduktion im mypy playground und den gezeigten Fehlern in main.py, unter Verwendung von mypy 0.981 auf Python 3.10 mit Standardeinstellungen. Verfolge, wie das String-Argument der Funktion und die Rückgabeannotation der Property geprüft werden; als abgeschlossen gilt die Aufgabe, wenn die Reproduktion ohne die gemeldeten Fehler ausgeführt wird und dabei das Verhalten der Funktion erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100