Skip to content
Myr

Check `~/.netrc` and `~/_netrc` files by default (#189)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Can Sarıgöl · committed by Seth Michael Larson · parent 92fbe5f · Browse files · 1 file+17 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−3 removed

  • other:+17 added−3 removed

1 file+17 added−3 removed

modified:httpx/utils.py+17 added-3 removed
81 unmodified lines
82 # Did not detect a valid UTF-32 ascii-range character83 return None848586NETRC_STATIC_FILES = tuple(87 os.path.expanduser(path) for path in ("~/.netrc", "~/_netrc")88)899091def get_netrc_login(host: str) -> typing.Optional[typing.Tuple[str, str, str]]:87 try:88 netrc_info = netrc.netrc(os.environ.get("NETRC")) # type: ignore89 except FileNotFoundError:92 NETRC_FILES = (93 (os.environ["NETRC"],) if "NETRC" in os.environ else NETRC_STATIC_FILES94 )95 netrc_path = None9697 for file_path in NETRC_FILES:98 if os.path.isfile(file_path):99 netrc_path = file_path100 break101102 if netrc_path is None:103 return None104105 netrc_info = netrc.netrc(netrc_path)106 return netrc_info.authenticators(host) # type: ignore