From: Tom Christie Date: Tue, 7 Jan 2020 12:24:26 +0000 (+0000) Subject: Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730) X-Git-Tag: 0.11.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5037f06e4ec1b550ee009147af052d9c2199ccb;p=thirdparty%2Fhttpx.git Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730) --- diff --git a/httpx/api.py b/httpx/api.py index c8b9f65f..bf9d6032 100644 --- a/httpx/api.py +++ b/httpx/api.py @@ -30,7 +30,6 @@ async def request( allow_redirects: bool = True, verify: VerifyTypes = True, cert: CertTypes = None, - stream: bool = False, trust_env: bool = True, ) -> Response: """ @@ -93,7 +92,6 @@ async def request( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, ) @@ -143,7 +141,6 @@ async def get( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, cert: CertTypes = None, @@ -165,7 +162,6 @@ async def get( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, @@ -181,7 +177,6 @@ async def options( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, cert: CertTypes = None, @@ -203,7 +198,6 @@ async def options( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, @@ -219,7 +213,6 @@ async def head( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = False, # Note: Differs to usual default. cert: CertTypes = None, @@ -243,7 +236,6 @@ async def head( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, @@ -262,7 +254,6 @@ async def post( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, cert: CertTypes = None, @@ -284,7 +275,6 @@ async def post( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, @@ -303,7 +293,6 @@ async def put( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, cert: CertTypes = None, @@ -325,7 +314,6 @@ async def put( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, @@ -344,7 +332,6 @@ async def patch( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, cert: CertTypes = None, @@ -366,7 +353,6 @@ async def patch( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, @@ -382,7 +368,6 @@ async def delete( params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, cert: CertTypes = None, @@ -404,7 +389,6 @@ async def delete( params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, cert=cert, diff --git a/httpx/client.py b/httpx/client.py index 224baad7..45b6ec70 100644 --- a/httpx/client.py +++ b/httpx/client.py @@ -1,6 +1,5 @@ import functools import typing -import warnings from types import TracebackType import hstspreload @@ -583,41 +582,10 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: - if cert is not None: # pragma: nocover - raise RuntimeError( - "Passing a 'cert' argument when making a request on a client " - "is not supported anymore. Instantiate a new client instead, " - "passing any 'cert' arguments to the client itself." - ) - - if verify is not None: # pragma: nocover - raise RuntimeError( - "Passing a 'verify' argument when making a request on a client " - "is not supported anymore. Instantiate a new client instead, " - "passing any 'verify' arguments to the client itself." - ) - - if trust_env is not None: # pragma: nocover - raise RuntimeError( - "Passing a 'trust_env' argument when making a request on a client " - "is not supported anymore. Instantiate a new client instead, " - "passing any 'trust_env' argument to the client itself." - ) - - if stream: # pragma: nocover - warnings.warn( - "The 'stream=True' argument is due to be deprecated. " - "Use 'async with client.stream(method, url, ...) as response' instead." - ) - request = self.build_request( method=method, url=url, @@ -629,11 +597,7 @@ class AsyncClient: cookies=cookies, ) response = await self.send( - request, - stream=stream, - auth=auth, - allow_redirects=allow_redirects, - timeout=timeout, + request, auth=auth, allow_redirects=allow_redirects, timeout=timeout, ) return response @@ -763,13 +727,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "GET", @@ -777,13 +737,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def options( @@ -793,13 +749,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "OPTIONS", @@ -807,13 +759,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def head( @@ -823,13 +771,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = False, # NOTE: Differs to usual default. - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "HEAD", @@ -837,13 +781,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def post( @@ -856,13 +796,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "POST", @@ -873,13 +809,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def put( @@ -892,13 +824,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "PUT", @@ -909,13 +837,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def patch( @@ -928,13 +852,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "PATCH", @@ -945,13 +865,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def delete( @@ -961,13 +877,9 @@ class AsyncClient: params: QueryParamTypes = None, headers: HeaderTypes = None, cookies: CookieTypes = None, - stream: bool = False, auth: AuthTypes = None, allow_redirects: bool = True, - cert: CertTypes = None, - verify: VerifyTypes = None, timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET, - trust_env: bool = None, ) -> Response: return await self.request( "DELETE", @@ -975,13 +887,9 @@ class AsyncClient: params=params, headers=headers, cookies=cookies, - stream=stream, auth=auth, allow_redirects=allow_redirects, - verify=verify, - cert=cert, timeout=timeout, - trust_env=trust_env, ) async def aclose(self) -> None: