]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Lazily import 'netrc' module (#2910)
authorTom Christie <tom@tomchristie.com>
Mon, 30 Oct 2023 20:07:42 +0000 (20:07 +0000)
committerGitHub <noreply@github.com>
Mon, 30 Oct 2023 20:07:42 +0000 (20:07 +0000)
httpx/_auth.py

index 27dc7f743bd179d1f9f63b01c7ffbd9a98a57358..c2c38f39455f6fe8a357e618f9e1d162a418e309 100644 (file)
@@ -1,5 +1,4 @@
 import hashlib
-import netrc
 import os
 import re
 import time
@@ -148,6 +147,10 @@ class NetRCAuth(Auth):
     """
 
     def __init__(self, file: typing.Optional[str] = None):
+        # Lazily import 'netrc'.
+        # There's no need for us to load this module unless 'NetRCAuth' is being used.
+        import netrc
+
         self._netrc_info = netrc.netrc(file)
 
     def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]: