Only allow splatting iterables if function takes at least one positional arg
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
At runtime the following code snippet:
def f(*, x: int = 9, y:int = 8) -> None:
pass
kwargs = {"x": 1, "y": 2}
f(*kwargs)
results in TypeError: f() takes 0 positional arguments but 2 were given. However, mypy does not report any issues.
To Reproduce
- Execute python interpreter for the code snipped above.
- Run mypy for the code snippet above.
Expected Behavior
Mypy should yield an error. For example pytype yields the following error:
Function f expects 0 arg(s), got 2 [wrong-arg-count]
Expected: (*, x, y)
Actually passed: (_, _)
Actual Behavior
Success: no issues found in 1 source file
Your Environment
- Mypy version used: 0.931
- Mypy command-line flags: None. Simply
mypy <FILENAME>. - Mypy configuration options from
mypy.ini(and other config files): N/A (defaults) - Python version used: 3.8.2
- Operating system and version: Mac OS Big Sur
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 im Issue beschriebenen Python-Reproducer und den mypy-Befehl auszuführen; verfolge dann, wie mypy ein starred iterable prüft, das an eine Funktion mit ausschließlich keyword-only parameters übergeben wird. Erledigt ist die Aufgabe, wenn mypy für dieses Beispiel einen Argumentanzahlfehler meldet und das Verhalten durch einen Regressionstest abgedeckt 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