Expand client docstrings (#1152)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Add AsyncClient.aclose to API documentation * Expand client docstrings * Add docstrings for all verbs and close methods * Include parameter merge information and see also * Update _client.py
authored by Felix Hildén · committed by GitHub · parent 45de714 · Browse files · 2 files·+143 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Tom Christie <tom@tomchristie.com>
Diff stats
2 files+143 added−1 removed
- other:+143 added−1 removed
Provenance
- Commit
f540bd0- Tree
14a3548- Author
Felix Hildén <felix.hilden@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
45de714
2 files changed+143 added−1 removed
modified:docs/api.md+1 added-1 removed
40 unmodified lines41424344454546474849108 unmodified linesExpand all40 unmodified lines## `AsyncClient`
::: httpx.AsyncClient :docstring: :members: headers cookies params request get head options post put patch delete build_request send :members: headers cookies params request get head options post put patch delete build_request send aclose
## `Response`
108 unmodified linesExpand allmodified:httpx/_client.py+142 added
206 unmodified lines207 cookies: CookieTypes = None,208 ) -> Request:209 """210 Build and return a request instance.211+212+ * The `params`, `headers` and `cookies` arguments213+ are merged with any values set on the client.214+ * The `url` argument is merged with any `base_url` set on the client.215+216+ See also: [Request instances][0]217+218+ [0]: /advanced/#request-instances219 """220 url = self._merge_url(url)221 headers = self._merge_headers(headers)222 cookies = self._merge_cookies(cookies)387 unmodified lines610 auth: AuthTypes = None,611 allow_redirects: bool = True,612 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,613 ) -> Response:614+ """615+ Build and send a request.616+617+ Equivalent to:618+619+ ```python620+ request = client.build_request(...)621+ response = client.send(request, ...)622+ ```623+624+ See `Client.build_request()`, `Client.send()` and625+ [Merging of configuration][0] for how the various parameters626+ are merged with client-level configuration.627+628+ [0]: /advanced/#merging-of-configuration629+ """630 request = self.build_request(631 method=method,632 url=url,633 data=data,15 unmodified lines649 auth: AuthTypes = None,650 allow_redirects: bool = True,651 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,652 ) -> Response:653+ """654+ Send a request.655+656+ The request is sent as-is, unmodified.657+658+ Typically you'll want to build one with `Client.build_request()`659+ so that any client-level configuration is merged into the request,660+ but passing an explicit `httpx.Request()` is supported as well.661+662+ See also: [Request instances][0]663+664+ [0]: /advanced/#request-instances665+ """666 timeout = self.timeout if isinstance(timeout, UnsetType) else Timeout(timeout)667 668 auth = self._build_auth(request, auth)669 125 unmodified lines795 auth: AuthTypes = None,796 allow_redirects: bool = True,797 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,798 ) -> Response:799+ """800+ Send a `GET` request.801+802+ **Parameters**: See `httpx.request`.803+ """804 return self.request(805 "GET",806 url,807 params=params,14 unmodified lines822 auth: AuthTypes = None,823 allow_redirects: bool = True,824 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,825 ) -> Response:826+ """827+ Send an `OPTIONS` request.828+829+ **Parameters**: See `httpx.request`.830+ """831 return self.request(832 "OPTIONS",833 url,834 params=params,14 unmodified lines849 auth: AuthTypes = None,850 allow_redirects: bool = False, # NOTE: Differs to usual default.851 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,852 ) -> Response:853+ """854+ Send a `HEAD` request.855+856+ **Parameters**: See `httpx.request`.857+ """858 return self.request(859 "HEAD",860 url,861 params=params,17 unmodified lines879 auth: AuthTypes = None,880 allow_redirects: bool = True,881 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,882 ) -> Response:883+ """884+ Send a `POST` request.885+886+ **Parameters**: See `httpx.request`.887+ """888 return self.request(889 "POST",890 url,891 data=data,20 unmodified lines912 auth: AuthTypes = None,913 allow_redirects: bool = True,914 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,915 ) -> Response:916+ """917+ Send a `PUT` request.918+919+ **Parameters**: See `httpx.request`.920+ """921 return self.request(922 "PUT",923 url,924 data=data,20 unmodified lines945 auth: AuthTypes = None,946 allow_redirects: bool = True,947 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,948 ) -> Response:949+ """950+ Send a `PATCH` request.951+952+ **Parameters**: See `httpx.request`.953+ """954 return self.request(955 "PATCH",956 url,957 data=data,17 unmodified lines975 auth: AuthTypes = None,976 allow_redirects: bool = True,977 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,978 ) -> Response:979+ """980+ Send a `DELETE` request.981+982+ **Parameters**: See `httpx.request`.983+ """984 return self.request(985 "DELETE",986 url,987 params=params,4 unmodified lines992 timeout=timeout,993 )994 995 def close(self) -> None:996+ """997+ Close transport and proxies.998+ """999 self._transport.close()1000 for proxy in self._proxies.values():1001 if proxy is not None:1002 proxy.close()208 unmodified lines1211 auth: AuthTypes = None,1212 allow_redirects: bool = True,1213 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1214 ) -> Response:1215+ """1216+ Build and send a request.1217+1218+ Equivalent to:1219+1220+ ```python1221+ request = client.build_request(...)1222+ response = client.send(request, ...)1223+ ```1224+1225+ See `AsyncClient.build_request()`, `AsyncClient.send()`1226+ and [Merging of configuration][0] for how the various parameters1227+ are merged with client-level configuration.1228+1229+ [0]: /advanced/#merging-of-configuration1230+ """1231 request = self.build_request(1232 method=method,1233 url=url,1234 data=data,16 unmodified lines1251 auth: AuthTypes = None,1252 allow_redirects: bool = True,1253 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1254 ) -> Response:1255+ """1256+ Send a request.1257+1258+ The request is sent as-is, unmodified.1259+1260+ Typically you'll want to build one with `AsyncClient.build_request()`1261+ so that any client-level configuration is merged into the request,1262+ but passing an explicit `httpx.Request()` is supported as well.1263+1264+ See also: [Request instances][0]1265+1266+ [0]: /advanced/#request-instances1267+ """1268 timeout = self.timeout if isinstance(timeout, UnsetType) else Timeout(timeout)1269 1270 auth = self._build_auth(request, auth)1271 127 unmodified lines1399 auth: AuthTypes = None,1400 allow_redirects: bool = True,1401 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1402 ) -> Response:1403+ """1404+ Send a `GET` request.1405+1406+ **Parameters**: See `httpx.request`.1407+ """1408 return await self.request(1409 "GET",1410 url,1411 params=params,14 unmodified lines1426 auth: AuthTypes = None,1427 allow_redirects: bool = True,1428 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1429 ) -> Response:1430+ """1431+ Send an `OPTIONS` request.1432+1433+ **Parameters**: See `httpx.request`.1434+ """1435 return await self.request(1436 "OPTIONS",1437 url,1438 params=params,14 unmodified lines1453 auth: AuthTypes = None,1454 allow_redirects: bool = False, # NOTE: Differs to usual default.1455 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1456 ) -> Response:1457+ """1458+ Send a `HEAD` request.1459+1460+ **Parameters**: See `httpx.request`.1461+ """1462 return await self.request(1463 "HEAD",1464 url,1465 params=params,17 unmodified lines1483 auth: AuthTypes = None,1484 allow_redirects: bool = True,1485 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1486 ) -> Response:1487+ """1488+ Send a `POST` request.1489+1490+ **Parameters**: See `httpx.request`.1491+ """1492 return await self.request(1493 "POST",1494 url,1495 data=data,20 unmodified lines1516 auth: AuthTypes = None,1517 allow_redirects: bool = True,1518 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1519 ) -> Response:1520+ """1521+ Send a `PUT` request.1522+1523+ **Parameters**: See `httpx.request`.1524+ """1525 return await self.request(1526 "PUT",1527 url,1528 data=data,20 unmodified lines1549 auth: AuthTypes = None,1550 allow_redirects: bool = True,1551 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1552 ) -> Response:1553+ """1554+ Send a `PATCH` request.1555+1556+ **Parameters**: See `httpx.request`.1557+ """1558 return await self.request(1559 "PATCH",1560 url,1561 data=data,17 unmodified lines1579 auth: AuthTypes = None,1580 allow_redirects: bool = True,1581 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1582 ) -> Response:1583+ """1584+ Send a `DELETE` request.1585+1586+ **Parameters**: See `httpx.request`.1587+ """1588 return await self.request(1589 "DELETE",1590 url,1591 params=params,4 unmodified lines1596 timeout=timeout,1597 )1598 1599 async def aclose(self) -> None:1600+ """1601+ Close transport and proxies.1602+ """1603 await self._transport.aclose()1604 for proxy in self._proxies.values():1605 if proxy is not None:1606 await proxy.aclose()72 unmodified lines