From: Tom Christie Date: Mon, 30 Oct 2023 20:07:42 +0000 (+0000) Subject: Lazily import 'netrc' module (#2910) X-Git-Tag: 0.25.1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad06741d1e0cfe4f5143c957c54f9a3fb8002e76;p=thirdparty%2Fhttpx.git Lazily import 'netrc' module (#2910) --- diff --git a/httpx/_auth.py b/httpx/_auth.py index 27dc7f74..c2c38f39 100644 --- a/httpx/_auth.py +++ b/httpx/_auth.py @@ -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]: