mypy does not recognize tuple unpacking syntax for TypeVars.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
This is really a minor issue, but if you declare multiple TypeVar variables in one line, mypy does not seem to recognize them as type variables. For example,
from typing import TypeVar, Generic
T1, T2 = TypeVar('T1'), TypeVar('T2')
class Container(Generic[T1]):
class Item(Generic[T2]):
pass
To Reproduce
- Declare more than one TypeVars in one line. (See the example code above.)
- Run mypy check on this script.
Expected Behavior
The T1 and T2 in the example above should be recognized as type variables.
They should pass mypy check.
Actual Behavior
Errors:
$ mypy typevar.py
typevar.py:5: error: Free type variable expected in Generic[...]
typevar.py:6: error: Free type variable expected in Generic[...]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.10.0
- Operating system and version: Ubuntu 20.04
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
Reproduziere das Problem mit dem bereitgestellten Python-Snippet und dem Befehl mypy typevar.py, und verfolge anschließend, wie per Tupel zugewiesene TypeVars erkannt werden, bevor Generic[...] geprüft wird. Erledigt ist die Aufgabe, wenn sowohl T1 als auch T2 als Typvariablen akzeptiert werden und das Beispiel mypy ohne Fehler durchläuft.
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
- 45/100