Skip to content

Commit e489c5a

Browse files
Cleanup
1 parent a455b50 commit e489c5a

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

variantlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from __future__ import annotations
22

33
__package_name__ = "variantlib"
4-
__version__ = "0.0.1"
4+
__version__ = "0.0.1.post1"

variantlib/plugins/loader.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self, python_ctx: BasePythonEnv | None = None) -> None:
6666

6767
def __enter__(self) -> Self:
6868
if self._python_ctx is None:
69-
raise RuntimeError("Impossible to load plugins without a Python Context")
69+
raise RuntimeError("Impossible to load plugins outside a Python Context")
7070

7171
self._load_all_plugins()
7272

@@ -84,18 +84,8 @@ def __exit__(self, *args: object) -> None:
8484
self._python_ctx = None
8585

8686
def _install_all_plugins_from_reqs(self, reqs: list[str]) -> None:
87-
if not isinstance(self._python_ctx, INSTALLER_PYTHON_ENVS):
88-
raise TypeError
89-
9087
if self._python_ctx is None:
91-
raise RuntimeError(
92-
"Impossible to install plugins outside of an installer context"
93-
)
94-
95-
if self._plugins is not None:
96-
raise RuntimeError(
97-
"Impossible to install plugins - `self._plugins` is not None"
98-
)
88+
raise RuntimeError("Impossible to load plugins outside a Python Context")
9989

10090
# Actual plugin installation
10191
self._python_ctx.install(reqs)
@@ -104,9 +94,7 @@ def _load_plugin(self, plugin_api: str) -> PluginType:
10494
"""Load a specific plugin"""
10595

10696
if self._python_ctx is None:
107-
raise RuntimeError(
108-
"Impossible to load a plugin outside of a python context"
109-
)
97+
raise RuntimeError("Impossible to load plugins outside a Python Context")
11098

11199
plugin_api_match = validate_matches_re(
112100
plugin_api, VALIDATION_PROVIDER_PLUGIN_API_REGEX
@@ -225,7 +213,7 @@ def _call(self, method: Callable[[], Any]) -> Any:
225213
def get_supported_configs(self) -> dict[str, ProviderConfig]:
226214
"""Get a mapping of namespaces to supported configs"""
227215
if self._python_ctx is None:
228-
raise RuntimeError("Impossible to access outside of an installer context")
216+
raise RuntimeError("Impossible to load plugins outside a Python Context")
229217

230218
provider_cfgs = {}
231219
for namespace, plugin_instance in self.plugins.items():
@@ -250,7 +238,7 @@ def get_supported_configs(self) -> dict[str, ProviderConfig]:
250238
def get_all_configs(self) -> dict[str, ProviderConfig]:
251239
"""Get a mapping of namespaces to all valid configs"""
252240
if self._python_ctx is None:
253-
raise RuntimeError("Impossible to access outside of an installer context")
241+
raise RuntimeError("Impossible to load plugins outside a Python Context")
254242

255243
provider_cfgs = {}
256244
for namespace, plugin_instance in self.plugins.items():
@@ -274,8 +262,8 @@ def get_all_configs(self) -> dict[str, ProviderConfig]:
274262

275263
def get_build_setup(self, properties: VariantDescription) -> dict[str, list[str]]:
276264
"""Get build variables for a variant made of specified properties"""
277-
if self._python_ctx is None or self.plugins is None:
278-
raise RuntimeError("Impossible to access outside of an installer context")
265+
if self._python_ctx is None:
266+
raise RuntimeError("Impossible to load plugins outside a Python Context")
279267

280268
ret_env: dict[str, list[str]] = {}
281269
for namespace, p_props in groupby(
@@ -304,17 +292,17 @@ def get_build_setup(self, properties: VariantDescription) -> dict[str, list[str]
304292
@property
305293
def plugins(self) -> dict[str, PluginType]:
306294
if self._python_ctx is None:
307-
raise RuntimeError("You can not access plugins outside of a python context")
295+
raise RuntimeError("Impossible to load plugins outside a Python Context")
308296
if self._plugins is None:
309-
raise NoPluginFoundError("No plugins have been loaded in the environment.")
297+
raise NoPluginFoundError("No plugin has been loaded in the environment.")
310298
return self._plugins
311299

312300
@property
313301
def plugin_api_values(self) -> dict[str, str]:
314302
if self._python_ctx is None:
315-
raise RuntimeError("You can not access plugins outside of a python context")
303+
raise RuntimeError("Impossible to load plugins outside a Python Context")
316304
if self._plugin_api_values is None:
317-
raise NoPluginFoundError("No plugins have been loaded in the environment.")
305+
raise NoPluginFoundError("No plugin has been loaded in the environment.")
318306
return self._plugin_api_values
319307

320308
@property
@@ -335,7 +323,7 @@ def __init__(
335323

336324
def __enter__(self) -> Self:
337325
if self._python_ctx is None:
338-
raise RuntimeError("Impossible to load plugins without a Python Context")
326+
raise RuntimeError("Impossible to load plugins outside a Python Context")
339327

340328
if isinstance(self._python_ctx, INSTALLER_PYTHON_ENVS):
341329
self._install_all_plugins()
@@ -459,7 +447,7 @@ def _load_all_plugins(self) -> None:
459447
@property
460448
def plugin_provider_packages(self) -> dict[str, Distribution]:
461449
if self._plugins is None:
462-
raise RuntimeError("You can not access plugins outside of a python context")
450+
raise NoPluginFoundError("No plugin has been loaded in the environment.")
463451
assert self._plugin_provider_packages is not None
464452
return self._plugin_provider_packages
465453

0 commit comments

Comments
 (0)