Support a method of copying function signature
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Capability to copy a functions signature, related to typing.ParamSpec.
def foo(a: str) -> None:
...
# pseudo code
def bar(*args: foo.args, **kwargs: foo.kwargs) -> foo.return_type:
return foo(*args, **kwargs)
Pitch
If I want to forward a call to another method in a type safe way it requires duplicating type definitions which can rapidly become unwieldy and error prone(especially if the function is in a third party module). I would love a way to just say that one functions signature is the same as another functions signature (with support for typing.Concatenate)
Maybe
extend functionality of ParamSpec to be generic to a Callable?
def bar(*args: ParamSpec[foo].args, **kwargs: ParamSpec[foo].kwargs) -> None:
return foo(*args, **kwargs)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the issue's examples and the discussion of typing.ParamSpec and typing.Concatenate. Review the related basedmypy issue for context. Done would mean defining and implementing an agreed mechanism for forwarding a function signature, including the behavior for arguments, keyword arguments, return types, and Concatenate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100