@@ -66,7 +66,7 @@ def __init__(self, python_ctx: BasePythonEnv | None = None) -> None:
66
66
67
67
def __enter__ (self ) -> Self :
68
68
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" )
70
70
71
71
self ._load_all_plugins ()
72
72
@@ -84,18 +84,8 @@ def __exit__(self, *args: object) -> None:
84
84
self ._python_ctx = None
85
85
86
86
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
-
90
87
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" )
99
89
100
90
# Actual plugin installation
101
91
self ._python_ctx .install (reqs )
@@ -104,9 +94,7 @@ def _load_plugin(self, plugin_api: str) -> PluginType:
104
94
"""Load a specific plugin"""
105
95
106
96
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" )
110
98
111
99
plugin_api_match = validate_matches_re (
112
100
plugin_api , VALIDATION_PROVIDER_PLUGIN_API_REGEX
@@ -225,7 +213,7 @@ def _call(self, method: Callable[[], Any]) -> Any:
225
213
def get_supported_configs (self ) -> dict [str , ProviderConfig ]:
226
214
"""Get a mapping of namespaces to supported configs"""
227
215
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 " )
229
217
230
218
provider_cfgs = {}
231
219
for namespace , plugin_instance in self .plugins .items ():
@@ -250,7 +238,7 @@ def get_supported_configs(self) -> dict[str, ProviderConfig]:
250
238
def get_all_configs (self ) -> dict [str , ProviderConfig ]:
251
239
"""Get a mapping of namespaces to all valid configs"""
252
240
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 " )
254
242
255
243
provider_cfgs = {}
256
244
for namespace , plugin_instance in self .plugins .items ():
@@ -274,8 +262,8 @@ def get_all_configs(self) -> dict[str, ProviderConfig]:
274
262
275
263
def get_build_setup (self , properties : VariantDescription ) -> dict [str , list [str ]]:
276
264
"""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 " )
279
267
280
268
ret_env : dict [str , list [str ]] = {}
281
269
for namespace , p_props in groupby (
@@ -304,17 +292,17 @@ def get_build_setup(self, properties: VariantDescription) -> dict[str, list[str]
304
292
@property
305
293
def plugins (self ) -> dict [str , PluginType ]:
306
294
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 " )
308
296
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." )
310
298
return self ._plugins
311
299
312
300
@property
313
301
def plugin_api_values (self ) -> dict [str , str ]:
314
302
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 " )
316
304
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." )
318
306
return self ._plugin_api_values
319
307
320
308
@property
@@ -335,7 +323,7 @@ def __init__(
335
323
336
324
def __enter__ (self ) -> Self :
337
325
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" )
339
327
340
328
if isinstance (self ._python_ctx , INSTALLER_PYTHON_ENVS ):
341
329
self ._install_all_plugins ()
@@ -459,7 +447,7 @@ def _load_all_plugins(self) -> None:
459
447
@property
460
448
def plugin_provider_packages (self ) -> dict [str , Distribution ]:
461
449
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. " )
463
451
assert self ._plugin_provider_packages is not None
464
452
return self ._plugin_provider_packages
465
453
0 commit comments