Coverage for src/dependenpy/_internal/plugins.py: 29.17%
22 statements
« prev ^ index » next coverage.py v7.10.5, created at 2025-08-24 18:36 +0200
« prev ^ index » next coverage.py v7.10.5, created at 2025-08-24 18:36 +0200
1from __future__ import annotations
3from dependenpy._internal.dsm import DSM as DependenpyDSM # noqa: N811
4from dependenpy._internal.helpers import guess_depth
6try:
7 import archan
8except ImportError:
10 class InternalDependencies:
11 """Empty dependenpy provider."""
13else:
15 class InternalDependencies(archan.Provider): # type: ignore[no-redef]
16 """Dependenpy provider for Archan."""
18 identifier = "dependenpy.InternalDependencies"
19 """Identifier of the provider."""
20 name = "Internal Dependencies"
21 """Name of the provider."""
22 description = "Provide matrix data about internal dependencies in a set of packages."
23 """Description of the provider."""
24 argument_list = (
25 archan.Argument("packages", list, "The list of packages to check for."),
26 archan.Argument(
27 "enforce_init",
28 bool,
29 default=True,
30 description="Whether to assert presence of __init__.py files in directories.",
31 ),
32 archan.Argument("depth", int, "The depth of the matrix to generate."),
33 )
34 """List of arguments for the provider."""
36 def get_data(
37 self,
38 packages: list[str],
39 enforce_init: bool = True, # noqa: FBT001,FBT002
40 depth: int | None = None,
41 ) -> archan.DSM:
42 """Provide matrix data for internal dependencies in a set of packages.
44 Args:
45 packages: the list of packages to check for.
46 enforce_init: whether to assert presence of __init__.py files in directories.
47 depth: the depth of the matrix to generate.
49 Returns:
50 Instance of archan DSM.
51 """
52 dsm = DependenpyDSM(*packages, enforce_init=enforce_init)
53 if depth is None:
54 depth = guess_depth(packages)
55 matrix = dsm.as_matrix(depth=depth)
56 return archan.DesignStructureMatrix(data=matrix.data, entities=matrix.keys)