Coverage for /usr/local/lib/python3.12/site-packages/prefect/deployments/__init__.py: 67%

18 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 10:48 +0000

1from typing import TYPE_CHECKING 1a

2from prefect._internal.compatibility.migration import getattr_migration 1a

3 

4 

5if TYPE_CHECKING: 5 ↛ 6line 5 didn't jump to line 6 because the condition on line 5 was never true1a

6 from .flow_runs import run_deployment 

7 from .base import initialize_project 

8 from .runner import deploy 

9 

10_public_api: dict[str, tuple[str, str]] = { 1a

11 "initialize_project": (__spec__.parent, ".base"), 

12 "run_deployment": (__spec__.parent, ".flow_runs"), 

13 "deploy": (__spec__.parent, ".runner"), 

14} 

15 

16# Declare API for type-checkers 

17__all__ = ["initialize_project", "deploy", "run_deployment"] 1a

18 

19 

20def __getattr__(attr_name: str) -> object: 1a

21 dynamic_attr = _public_api.get(attr_name) 1a

22 if dynamic_attr is None: 22 ↛ 23line 22 didn't jump to line 23 because the condition on line 22 was never true1a

23 return getattr_migration(__name__)(attr_name) 

24 

25 package, module_name = dynamic_attr 1a

26 

27 from importlib import import_module 1a

28 

29 if module_name == "__module__": 29 ↛ 30line 29 didn't jump to line 30 because the condition on line 29 was never true1a

30 return import_module(f".{attr_name}", package=package) 

31 else: 

32 module = import_module(module_name, package=package) 1a

33 return getattr(module, attr_name) 1a