@@ -767,6 +767,9 @@ def __init__(self, **kwargs: Any) -> None:
767767
768768class SyncHttpxClientWrapper (DefaultHttpxClient ):
769769 def __del__ (self ) -> None :
770+ if self .is_closed :
771+ return
772+
770773 try :
771774 self .close ()
772775 except Exception :
@@ -792,6 +795,7 @@ def __init__(
792795 custom_query : Mapping [str , object ] | None = None ,
793796 _strict_response_validation : bool ,
794797 ) -> None :
798+ kwargs : dict [str , Any ] = {}
795799 if limits is not None :
796800 warnings .warn (
797801 "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead" ,
@@ -804,6 +808,7 @@ def __init__(
804808 limits = DEFAULT_CONNECTION_LIMITS
805809
806810 if transport is not None :
811+ kwargs ["transport" ] = transport
807812 warnings .warn (
808813 "The `transport` argument is deprecated. The `http_client` argument should be passed instead" ,
809814 category = DeprecationWarning ,
@@ -813,6 +818,7 @@ def __init__(
813818 raise ValueError ("The `http_client` argument is mutually exclusive with `transport`" )
814819
815820 if proxies is not None :
821+ kwargs ["proxies" ] = proxies
816822 warnings .warn (
817823 "The `proxies` argument is deprecated. The `http_client` argument should be passed instead" ,
818824 category = DeprecationWarning ,
@@ -856,10 +862,9 @@ def __init__(
856862 base_url = base_url ,
857863 # cast to a valid type because mypy doesn't understand our type narrowing
858864 timeout = cast (Timeout , timeout ),
859- proxies = proxies ,
860- transport = transport ,
861865 limits = limits ,
862866 follow_redirects = True ,
867+ ** kwargs , # type: ignore
863868 )
864869
865870 def is_closed (self ) -> bool :
@@ -1332,6 +1337,9 @@ def __init__(self, **kwargs: Any) -> None:
13321337
13331338class AsyncHttpxClientWrapper (DefaultAsyncHttpxClient ):
13341339 def __del__ (self ) -> None :
1340+ if self .is_closed :
1341+ return
1342+
13351343 try :
13361344 # TODO(someday): support non asyncio runtimes here
13371345 asyncio .get_running_loop ().create_task (self .aclose ())
@@ -1358,6 +1366,7 @@ def __init__(
13581366 custom_headers : Mapping [str , str ] | None = None ,
13591367 custom_query : Mapping [str , object ] | None = None ,
13601368 ) -> None :
1369+ kwargs : dict [str , Any ] = {}
13611370 if limits is not None :
13621371 warnings .warn (
13631372 "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead" ,
@@ -1370,6 +1379,7 @@ def __init__(
13701379 limits = DEFAULT_CONNECTION_LIMITS
13711380
13721381 if transport is not None :
1382+ kwargs ["transport" ] = transport
13731383 warnings .warn (
13741384 "The `transport` argument is deprecated. The `http_client` argument should be passed instead" ,
13751385 category = DeprecationWarning ,
@@ -1379,6 +1389,7 @@ def __init__(
13791389 raise ValueError ("The `http_client` argument is mutually exclusive with `transport`" )
13801390
13811391 if proxies is not None :
1392+ kwargs ["proxies" ] = proxies
13821393 warnings .warn (
13831394 "The `proxies` argument is deprecated. The `http_client` argument should be passed instead" ,
13841395 category = DeprecationWarning ,
@@ -1422,10 +1433,9 @@ def __init__(
14221433 base_url = base_url ,
14231434 # cast to a valid type because mypy doesn't understand our type narrowing
14241435 timeout = cast (Timeout , timeout ),
1425- proxies = proxies ,
1426- transport = transport ,
14271436 limits = limits ,
14281437 follow_redirects = True ,
1438+ ** kwargs , # type: ignore
14291439 )
14301440
14311441 def is_closed (self ) -> bool :
0 commit comments