Coverage for src/dependenpy/plugins.py: 0.00%

18 statements  

« prev     ^ index     » next       coverage.py v6.4.1, created at 2022-09-04 11:35 +0200

1"""dependenpy plugins module.""" 

2 

3from __future__ import annotations 

4 

5from dependenpy.dsm import DSM as DependenpyDSM # noqa: N811 

6from dependenpy.helpers import guess_depth 

7 

8try: 

9 import archan 

10except ImportError: 

11 

12 class InternalDependencies(object): 

13 """Empty dependenpy provider.""" 

14 

15else: 

16 

17 class InternalDependencies(archan.Provider): # type: ignore # noqa: WPS440 

18 """Dependenpy provider for Archan.""" 

19 

20 identifier = "dependenpy.InternalDependencies" 

21 name = "Internal Dependencies" 

22 description = "Provide matrix data about internal dependencies in a set of packages." 

23 argument_list = ( 

24 archan.Argument("packages", list, "The list of packages to check for."), 

25 archan.Argument( 

26 "enforce_init", 

27 bool, 

28 default=True, 

29 description="Whether to assert presence of __init__.py files in directories.", 

30 ), 

31 archan.Argument("depth", int, "The depth of the matrix to generate."), 

32 ) 

33 

34 def get_data(self, packages: list[str], enforce_init: bool = True, depth: int = None) -> archan.DSM: 

35 """ 

36 Provide matrix data for internal dependencies in a set of packages. 

37 

38 Args: 

39 packages: the list of packages to check for. 

40 enforce_init: whether to assert presence of __init__.py files in directories. 

41 depth: the depth of the matrix to generate. 

42 

43 Returns: 

44 Instance of archan DSM. 

45 """ 

46 dsm = DependenpyDSM(*packages, enforce_init=enforce_init) 

47 if depth is None: 

48 depth = guess_depth(packages) 

49 matrix = dsm.as_matrix(depth=depth) 

50 return archan.DesignStructureMatrix(data=matrix.data, entities=matrix.keys)