-
Notifications
You must be signed in to change notification settings - Fork 262
Open
Assignees
Labels
@Zeroto521
Description
Since Python3.5 supports for type hints.
It could be better than writing docstring at sometimes.
Such as follow example.
We can learn from code a lot directly rather than docstring.
Before
def get(url, qsargs=None, timeout=5.0): """Send an HTTP GET request. :param url: URL for the new request. :type url: str :param qsargs: Converted to query string arguments. :type qsargs: dict :param timeout: In seconds. :rtype: mymodule.Response """ return request('get', url, qsargs=qsargs, timeout=timeout)
Later
from typing import Dict, Optional def get(url: str, qsargs: Optional[Dict] = None, timeout: float = 5.0) -> mymodule.Response: """Send an HTTP GET request. :param url: URL for the new request. :param qsargs: Converted to query string arguments. :param timeout: In seconds. """ return request('get', url, qsargs=qsargs, timeout=timeout)