Skip to content
Myr

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

2 files+143 added−1 removed

modified:docs/api.md+1 added-1 removed
modified:httpx/_client.py+142 added
206 unmodified lines
207 cookies: CookieTypes = None,208 ) -> Request:209 """210 Build and return a request instance.211212 * 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.215216 See also: [Request instances][0]217218 [0]: /advanced/#request-instances219 """220 url = self._merge_url(url)221 headers = self._merge_headers(headers)222 cookies = self._merge_cookies(cookies)
387 unmodified lines
610 auth: AuthTypes = None,611 allow_redirects: bool = True,612 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,613 ) -> Response:614 """615 Build and send a request.616617 Equivalent to:618619 ```python620 request = client.build_request(...)621 response = client.send(request, ...)622 ```623624 See `Client.build_request()`, `Client.send()` and625 [Merging of configuration][0] for how the various parameters626 are merged with client-level configuration.627628 [0]: /advanced/#merging-of-configuration629 """630 request = self.build_request(631 method=method,632 url=url,633 data=data,
15 unmodified lines
649 auth: AuthTypes = None,650 allow_redirects: bool = True,651 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,652 ) -> Response:653 """654 Send a request.655656 The request is sent as-is, unmodified.657658 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.661662 See also: [Request instances][0]663664 [0]: /advanced/#request-instances665 """666 timeout = self.timeout if isinstance(timeout, UnsetType) else Timeout(timeout)667668 auth = self._build_auth(request, auth)669
125 unmodified lines
795 auth: AuthTypes = None,796 allow_redirects: bool = True,797 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,798 ) -> Response:799 """800 Send a `GET` request.801802 **Parameters**: See `httpx.request`.803 """804 return self.request(805 "GET",806 url,807 params=params,
14 unmodified lines
822 auth: AuthTypes = None,823 allow_redirects: bool = True,824 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,825 ) -> Response:826 """827 Send an `OPTIONS` request.828829 **Parameters**: See `httpx.request`.830 """831 return self.request(832 "OPTIONS",833 url,834 params=params,
14 unmodified lines
849 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.855856 **Parameters**: See `httpx.request`.857 """858 return self.request(859 "HEAD",860 url,861 params=params,
17 unmodified lines
879 auth: AuthTypes = None,880 allow_redirects: bool = True,881 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,882 ) -> Response:883 """884 Send a `POST` request.885886 **Parameters**: See `httpx.request`.887 """888 return self.request(889 "POST",890 url,891 data=data,
20 unmodified lines
912 auth: AuthTypes = None,913 allow_redirects: bool = True,914 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,915 ) -> Response:916 """917 Send a `PUT` request.918919 **Parameters**: See `httpx.request`.920 """921 return self.request(922 "PUT",923 url,924 data=data,
20 unmodified lines
945 auth: AuthTypes = None,946 allow_redirects: bool = True,947 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,948 ) -> Response:949 """950 Send a `PATCH` request.951952 **Parameters**: See `httpx.request`.953 """954 return self.request(955 "PATCH",956 url,957 data=data,
17 unmodified lines
975 auth: AuthTypes = None,976 allow_redirects: bool = True,977 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,978 ) -> Response:979 """980 Send a `DELETE` request.981982 **Parameters**: See `httpx.request`.983 """984 return self.request(985 "DELETE",986 url,987 params=params,
4 unmodified lines
992 timeout=timeout,993 )994995 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 lines
1211 auth: AuthTypes = None,1212 allow_redirects: bool = True,1213 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1214 ) -> Response:1215 """1216 Build and send a request.12171218 Equivalent to:12191220 ```python1221 request = client.build_request(...)1222 response = client.send(request, ...)1223 ```12241225 See `AsyncClient.build_request()`, `AsyncClient.send()`1226 and [Merging of configuration][0] for how the various parameters1227 are merged with client-level configuration.12281229 [0]: /advanced/#merging-of-configuration1230 """1231 request = self.build_request(1232 method=method,1233 url=url,1234 data=data,
16 unmodified lines
1251 auth: AuthTypes = None,1252 allow_redirects: bool = True,1253 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1254 ) -> Response:1255 """1256 Send a request.12571258 The request is sent as-is, unmodified.12591260 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.12631264 See also: [Request instances][0]12651266 [0]: /advanced/#request-instances1267 """1268 timeout = self.timeout if isinstance(timeout, UnsetType) else Timeout(timeout)12691270 auth = self._build_auth(request, auth)1271
127 unmodified lines
1399 auth: AuthTypes = None,1400 allow_redirects: bool = True,1401 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1402 ) -> Response:1403 """1404 Send a `GET` request.14051406 **Parameters**: See `httpx.request`.1407 """1408 return await self.request(1409 "GET",1410 url,1411 params=params,
14 unmodified lines
1426 auth: AuthTypes = None,1427 allow_redirects: bool = True,1428 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1429 ) -> Response:1430 """1431 Send an `OPTIONS` request.14321433 **Parameters**: See `httpx.request`.1434 """1435 return await self.request(1436 "OPTIONS",1437 url,1438 params=params,
14 unmodified lines
1453 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.14591460 **Parameters**: See `httpx.request`.1461 """1462 return await self.request(1463 "HEAD",1464 url,1465 params=params,
17 unmodified lines
1483 auth: AuthTypes = None,1484 allow_redirects: bool = True,1485 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1486 ) -> Response:1487 """1488 Send a `POST` request.14891490 **Parameters**: See `httpx.request`.1491 """1492 return await self.request(1493 "POST",1494 url,1495 data=data,
20 unmodified lines
1516 auth: AuthTypes = None,1517 allow_redirects: bool = True,1518 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1519 ) -> Response:1520 """1521 Send a `PUT` request.15221523 **Parameters**: See `httpx.request`.1524 """1525 return await self.request(1526 "PUT",1527 url,1528 data=data,
20 unmodified lines
1549 auth: AuthTypes = None,1550 allow_redirects: bool = True,1551 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1552 ) -> Response:1553 """1554 Send a `PATCH` request.15551556 **Parameters**: See `httpx.request`.1557 """1558 return await self.request(1559 "PATCH",1560 url,1561 data=data,
17 unmodified lines
1579 auth: AuthTypes = None,1580 allow_redirects: bool = True,1581 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1582 ) -> Response:1583 """1584 Send a `DELETE` request.15851586 **Parameters**: See `httpx.request`.1587 """1588 return await self.request(1589 "DELETE",1590 url,1591 params=params,
4 unmodified lines
1596 timeout=timeout,1597 )15981599 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