Skip to content

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

Open
@Zac-HD

Description

@Zac-HD

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-typingtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions