Coverage for src/lilbee/providers/availability.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-11-06 08:17 +0000

1"""Install check for the client library behind the provider backends.""" 

2 

3from __future__ import annotations 

4 

5import functools 

6from importlib.metadata import PackageNotFoundError 

7from importlib.metadata import version as _dist_version 

8 

9PROVIDER_SDK_MISSING_MESSAGE = ( 

10 "Remote and API models need the lilbee[providers] extra. If you installed lilbee " 

11 "with uv tool install, run your install command again with providers added to the " 

12 "extras. If you installed lilbee with pip, run: pip install 'lilbee[providers]'." 

13) 

14 

15 

16@functools.cache 

17def provider_sdk_available() -> bool: 

18 """Return True if the provider client distribution is installed. 

19 

20 Reads package metadata instead of importing the native module, so the 

21 Settings screen's compose does not pay for the import. 

22 """ 

23 # circular: the factory imports this module for its REMOTE refusal 

24 from lilbee.providers.factory import sdk_library 

25 

26 try: 

27 _dist_version(sdk_library().dist) 

28 except PackageNotFoundError: 

29 return False 

30 return True