Load plugins from disk.
(settings, cwd: str | Path, extra_roots: Iterable[str | Path] | None = None)
| 105 | |
| 106 | |
| 107 | def load_plugins(settings, cwd: str | Path, extra_roots: Iterable[str | Path] | None = None) -> list[LoadedPlugin]: |
| 108 | """Load plugins from disk.""" |
| 109 | project_plugins_dir = get_project_plugins_dir(cwd) |
| 110 | if not getattr(settings, "allow_project_plugins", False) and any( |
| 111 | path.is_dir() and _find_manifest(path) is not None for path in sorted(project_plugins_dir.iterdir()) |
| 112 | ): |
| 113 | logger.warning( |
| 114 | "Found project-local plugins in %s, but they are disabled by default. " |
| 115 | "Set allow_project_plugins=true if you trust this workspace.", |
| 116 | project_plugins_dir, |
| 117 | ) |
| 118 | plugins: list[LoadedPlugin] = [] |
| 119 | for path in discover_plugin_paths_for_settings(settings, cwd, extra_roots=extra_roots): |
| 120 | plugin = load_plugin(path, settings.enabled_plugins) |
| 121 | if plugin is not None: |
| 122 | plugins.append(plugin) |
| 123 | return plugins |
| 124 | |
| 125 | |
| 126 | def load_plugin(path: Path, enabled_plugins: dict[str, bool]) -> LoadedPlugin | None: |