python / python/cpython

Support `typing.get_type_hints(partial(fn, ...))` by 'unwrapping' the `partial`, and discarding hints for bound arguments

Aperta
#131,391 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib topic-typing type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

We added this to Hypothesis' get_type_hints() helper a few years ago, and while most of that function is clearly not suitable to upstream, it struck me recently that "works with functools.partial" could quite reasonably be added to the stdlib function.

It's also plausible that the typing module prefers to avoid calling inspect.signature, though I don't have a great sense of how to determine which parameters have been bound without getting the signature of the partial object. In any case, the implementation need not be the same as in Hypothesis, although as the author you're welcome to use that code if you'd like.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo l’implementazione esistente di typing.get_type_hints e l’helper di Hypothesis referenziato in hypothesis-python/src/hypothesis/internal/compat.py. Verifica come functools.partial e inspect.signature espongono gli argomenti associati, quindi definisci test che dimostrino che i partial vengono scomposti e che le annotazioni degli argomenti associati vengono scartate. Il lavoro è completato quando il comportamento è coperto senza compromettere i casi esistenti di get_type_hints.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.