|
11 | 11 | from pathlib import Path
|
12 | 12 | from subprocess import run
|
13 | 13 | from tempfile import TemporaryDirectory
|
14 |
| -from types import MethodType |
15 | 14 | from typing import TYPE_CHECKING
|
16 | 15 | from typing import Any
|
17 |
| -from typing import get_type_hints |
18 | 16 |
|
19 | 17 | from packaging.markers import Marker
|
20 | 18 | from packaging.markers import default_environment
|
|
24 | 22 | from variantlib.errors import NoPluginFoundError
|
25 | 23 | from variantlib.errors import PluginError
|
26 | 24 | from variantlib.errors import PluginMissingError
|
27 |
| -from variantlib.errors import ValidationError |
28 | 25 | from variantlib.models.provider import ProviderConfig
|
29 | 26 | from variantlib.models.provider import VariantFeatureConfig
|
30 | 27 | from variantlib.plugins.py_envs import INSTALLER_PYTHON_ENVS
|
31 | 28 | from variantlib.plugins.py_envs import AutoPythonEnv
|
32 | 29 | from variantlib.plugins.py_envs import BasePythonEnv
|
33 | 30 | from variantlib.plugins.py_envs import ExternalNonIsolatedPythonEnv
|
34 |
| -from variantlib.protocols import PluginType |
35 | 31 | from variantlib.validators.base import validate_matches_re
|
36 |
| -from variantlib.validators.base import validate_type |
37 | 32 |
|
38 | 33 | if TYPE_CHECKING:
|
39 |
| - from collections.abc import Callable |
40 |
| - |
41 | 34 | from variantlib.models.metadata import VariantMetadata
|
42 | 35 | from variantlib.models.variant import VariantDescription
|
43 | 36 |
|
@@ -179,24 +172,6 @@ def _load_all_plugins_from_tuple(self, plugin_apis: list[str]) -> None:
|
179 | 172 | "Impossible to load `%s`", plugin_api, exc_info=sys.exc_info()
|
180 | 173 | )
|
181 | 174 |
|
182 |
| - def _call(self, method: Callable[[], Any]) -> Any: |
183 |
| - """Call plugin method and verify the return type""" |
184 |
| - |
185 |
| - value = method() |
186 |
| - |
187 |
| - try: |
188 |
| - validate_type(value, get_type_hints(method)["return"]) |
189 |
| - except ValidationError as err: |
190 |
| - assert isinstance(method, MethodType) |
191 |
| - plugin_instance = method.__self__ |
192 |
| - assert isinstance(plugin_instance, PluginType) |
193 |
| - raise TypeError( |
194 |
| - f"Provider {plugin_instance.namespace}, {method.__func__.__name__}() " |
195 |
| - f"method returned incorrect type. {err}" |
196 |
| - ) from None |
197 |
| - |
198 |
| - return value |
199 |
| - |
200 | 175 | def _check_plugins_loaded(self) -> None:
|
201 | 176 | if self._python_ctx is None:
|
202 | 177 | raise RuntimeError("Impossible to load plugins outside a Python Context")
|
|
0 commit comments