Skip to content

Commit e6e42de

Browse files
committed
Move keyring import
1 parent c04222f commit e6e42de

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/pip/_internal/network/auth.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import subprocess
1010
import urllib.parse
1111
from abc import ABC, abstractmethod
12-
from types import ModuleType
1312
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
1413

1514
from pip._vendor.requests.auth import AuthBase, HTTPBasicAuth
@@ -62,8 +61,10 @@ def save_auth_info(self, url: str, username: str, password: str) -> None:
6261
class KeyRingPythonProvider(KeyRingBaseProvider):
6362
"""Keyring interface which uses locally imported `keyring`"""
6463

65-
def __init__(self, module: ModuleType) -> None:
66-
self.keyring = module
64+
def __init__(self) -> None:
65+
import keyring
66+
67+
self.keyring = keyring
6768

6869
def get_auth_info(self, url: str, username: Optional[str]) -> Optional[AuthInfo]:
6970
# Support keyring's get_credential interface which supports getting
@@ -147,9 +148,7 @@ def get_keyring_provider() -> KeyRingBaseProvider:
147148
# keyring has previously failed and been disabled
148149
if not KEYRING_DISABLED:
149150
try:
150-
import keyring
151-
152-
return KeyRingPythonProvider(keyring)
151+
return KeyRingPythonProvider()
153152
except ImportError:
154153
pass
155154
cli = shutil.which("keyring")

0 commit comments

Comments
 (0)