Type checking for *args and **kwargs when passing them to another function
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 302
- Merge medio
- 23h
- PR unite (30g)
- 8
Descrizione
Problem:
I am writing a python application, and I made a function that creates an object and passes its additional *args and **kwargs to object's constructor and takes few its own arguments. I want to make *args and **kwargs typed exactly as inner function's arguments.
Description and examples:
A simple example with two functions:
def inner(a: int, b: int) -> None:
...
def wrapper(arg1: str, *args, **kwargs) -> None:
inner(*args, **kwargs) # It will automatically detect passing arguments to another function
In my case, inner is object constructor, I gave an example with functions to make it more simple.
Type checkers should see wrapper's signature like this:
def wrapper(arg1: str, a: int, b: int):
...
It may be enabled by default when passing *args and **kwargs to another function is detected or it may be enabled by adding a decorator to the function.
Detailed description:
Already suggested this to mypy, detailed description of this feature can be found here: python/mypy#19302.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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 con gli esempi di wrapper e di funzione interna nell’issue, poi leggi la discussione collegata mypy#19302 sulla proposta esistente e sui vincoli. Il lavoro sarà completato quando sarà disponibile un approccio documentato e concordato per derivare o dichiarare i tipi degli argomenti del wrapper dalla funzione o dal costruttore che riceve *args e **kwargs.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100