MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / discover_plugins

Function discover_plugins

commitizen/cz/__init__.py:16–40  ·  view source on GitHub ↗

Discover commitizen plugins on the path Args: path (Path, optional): If provided, 'path' should be either None or a list of paths to look for modules in. If path is None, all top-level modules on sys.path.. Defaults to None. Returns: Dict[str, Type[BaseCommitizen]]: Reg

(
    path: Iterable[str] | None = None,
)

Source from the content-addressed store, hash-verified

14
15
16def discover_plugins(
17 path: Iterable[str] | None = None,
18) -> dict[str, type[BaseCommitizen]]:
19 """Discover commitizen plugins on the path
20
21 Args:
22 path (Path, optional): If provided, 'path' should be either None or a list of paths to look for
23 modules in. If path is None, all top-level modules on sys.path.. Defaults to None.
24
25 Returns:
26 Dict[str, Type[BaseCommitizen]]: Registry with found plugins
27 """
28 for _, name, _ in pkgutil.iter_modules(path):
29 if name.startswith("cz_"):
30 mod = importlib.import_module(name)
31 if hasattr(mod, "discover_this"):
32 warnings.warn(
33 UserWarning(
34 f"Legacy plugin '{name}' has been ignored: please expose it the 'commitizen.plugin' entrypoint"
35 )
36 )
37
38 return {
39 ep.name: ep.load() for ep in metadata.entry_points(group="commitizen.plugin")
40 }
41
42
43registry: dict[str, type[BaseCommitizen]] = discover_plugins()

Callers 4

test_discover_pluginsFunction · 0.90
__init__.pyFile · 0.85

Calls

no outgoing calls

Tested by 3

test_discover_pluginsFunction · 0.72