Skip to content

Commit

Permalink
Lazily import 'netrc' module (#2910)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie authored Oct 30, 2023
1 parent 9751f76 commit ad06741
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion httpx/_auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import hashlib
import netrc
import os
import re
import time
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit ad06741

Please sign in to comment.