Closed
Description
Is there a way to inherit a type signature from another method? The most common use case for this is when we've got some convenience method like requests.post
Below is a super simple version of https://github.com/kennethreitz/requests/blob/master/requests/api.py#L99 which eventually calls down into https://github.com/kennethreitz/requests/blob/master/requests/sessions.py#L397
def request(method: str, url: str, data: Optional[Dict[str, Any]]=None, headers: Optional[Dict[str, str]]=None) -> Response:
pass
def post(url: str, **kwargs) -> Response:
# Would like to be able to annotate that **kwargs should inherit from `request`
return request('post', url, **kwargs)
post('http://foo.com', headers={'timeout': 32}) # Should fail.
Ideally I wouldn't have to copy and paste the type signature of request
into post
.
Metadata
Metadata
Assignees
Labels
No labels