Support `typing.get_type_hints(partial(fn, ...))` by 'unwrapping' the `partial`, and discarding hints for bound arguments
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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.
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
Beginnen Sie damit, die bestehende Implementierung von typing.get_type_hints und den referenzierten Hypothesis-Helfer in hypothesis-python/src/hypothesis/internal/compat.py zu lesen. Prüfen Sie, wie functools.partial und inspect.signature gebundene Argumente offenlegen, und definieren Sie anschließend Tests, die zeigen, dass partial-Objekte entpackt und Hinweise für gebundene Argumente verworfen werden. Als erledigt gilt die Aufgabe, wenn das Verhalten abgedeckt ist, ohne bestehende Fälle von get_type_hints zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100