False-positive with multiple *args splats in a function call
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 falsely(?) reports a type error when the *args syntax is used more than once in a function call.
To Reproduce
mypy --no-incremental --config /dev/null -c '
def foobar(a: int, b: str, c: int) -> None:
...
foo = (1,)
bar = ("b", 3)
foobar(*foo, *bar)
'
Expected Behavior
Success: no issues found in 1 source file
Actual Behavior
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "str"
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "int"
This error goes away if I:
- make
fooanintinstead ofTuple[int], and remove the splat whenfoobar()is called. - make
bartwo ints and makefoobar()take three int arguments. - make
fooaTuple[str, int]and makefoobar()takestr, int, str, intarguments. - make
barjust aTuple[str]and makefoobar()takeint, strarguments.
Your Environment
This occurs with the standard version of mypy in Debian Testing:
$ /usr/bin/mypy --version
mypy 0.812
...as well as with the latest git revision:
$ ~/.local/pipx/venvs/mypy/bin/mypy --version
mypy 0.820+dev.8642b351cff94c471333256f9cd6867807384f01
In both cases, I'm using the Debian-provided Python 3.9.2,
on up-to-date Debian Testing.
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, den bereitgestellten mypy-Befehl auszuführen und die beiden Diagnosen für den Aufruf mit mehreren Tuple-Splats zu bestätigen. Verfolge anschließend die Prüfung der Aufrufargumente und die Behandlung von Tuple-Splats und füge eine Testabdeckung für diesen Reproducer hinzu; abgeschlossen ist die Aufgabe, wenn der Befehl ohne Probleme meldet, dass keine der aufgeführten Variationen regressiert ist.
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
- 45/100