"object" not callable when creating an instance of tuple by using type alias
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
Mypy shows an error when creating an instance of tuple by using type alias. Error is not present when doing the same with type alias of a list. It's likely caused by the way tuples are instantiated directly from the __new__ method.
To Reproduce
Vector = tuple[int]
v = Vector([1,2,3])
Expected Behavior
No error
Actual Behavior
error: "object" not callable
Your Environment
- Mypy version used: 0.812
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.9.2
- Operating system and version: Windows 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 dem Reproduktionsbeispiel unter Verwendung von Vector = tuple[int] und Vector([1,2,3]), und vergleiche dann, wie mypy diesen Tupel-Alias mit dem entsprechenden Listen-Alias behandelt. Führe mypy für das Beispiel aus und verfolge die Tupel-Instanziierung sowie die Behandlung von __new__. Als erledigt gilt die Aufgabe, wenn die gültige Tupelkonstruktion nicht mehr "object" not callable meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100