Load auth config, using override if set (for testing). The result is cached per-process so ``auth.json`` is read at most once, and any warning about a malformed file fires only once.
()
| 26 | |
| 27 | |
| 28 | def _load_config() -> list[AuthConfigEntry]: |
| 29 | """Load auth config, using override if set (for testing). |
| 30 | |
| 31 | The result is cached per-process so ``auth.json`` is read at most once, |
| 32 | and any warning about a malformed file fires only once. |
| 33 | """ |
| 34 | global _config_cache |
| 35 | if _config_override is not None: |
| 36 | return _config_override |
| 37 | if _config_cache is not None: |
| 38 | return _config_cache |
| 39 | try: |
| 40 | _config_cache = load_auth_config() |
| 41 | except (ValueError, OSError) as exc: |
| 42 | import warnings |
| 43 | config_path = _default_config_path() |
| 44 | warnings.warn( |
| 45 | f"Failed to load {config_path}: {exc}. " |
| 46 | "All requests will be unauthenticated.", |
| 47 | UserWarning, |
| 48 | stacklevel=2, |
| 49 | ) |
| 50 | _config_cache = [] |
| 51 | return _config_cache |
| 52 | |
| 53 | |
| 54 | def _hostname_in_hosts(hostname: str, hosts: tuple[str, ...]) -> bool: |
no test coverage detected