Report an error if *args or **kwargs are passed when all other arguments are filled.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug Report
You can pass **kwargs or *args to a function, even if all of its arguments are already passed. I would expect this to raise an error, since it's only valid for empty kwargs and args.
To Reproduce
playground link
def f(x: int) -> int:
return x + 1
def g(x: int, **kwargs) -> int:
return f(x, **kwargs)
def h(x: int, args: list[int]) -> int:
return f(x, *args)
g(1, bar=42)
h(2, [])
h(3, [1337])
Expected Behavior
In both g and h, the x argument is specified, so I would expecting passing **kwargs or *args to produce an error, since they can never correctly pass additional arguments.
Actual Behavior
Success: no issues found in 1 source file
Your Environment
I tried several versions of mypy (including 1.16.0 and master) with python3.12 in mypy playground.
I tried with both with and without --check-untyped-defs
** Related Issues
- This is a more general case of https://github.com/python/mypy/issues/13380 (that issue specifically mentions functions with no arguments)
- https://github.com/python/mypy/issues/12206 is another issue with splatting, but I don't think it's quite the same
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la riproduzione collegata in mypy playground e confronta il comportamento descritto per g e h. Esamina le issue correlate 13380 e 12206 per il contesto e l’ambito esistenti. Il lavoro è completato quando mypy segnala le chiamate non valide con argomenti splattati, preservando i casi validi di *args e **kwargs vuoti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100