nlsq.diagnostics.PluginRegistry¶
- class nlsq.diagnostics.PluginRegistry[source]¶
Bases:
objectGlobal registry for diagnostic plugins.
Thread-safe singleton for managing plugin registration. Plugins are stored by name and can be registered, unregistered, retrieved, or listed.
This class uses class-level storage and methods, so it acts as a singleton without explicit instantiation.
Example
>>> from nlsq.diagnostics import PluginRegistry >>> # Register a plugin >>> PluginRegistry.register(my_plugin) >>> # Get a plugin by name >>> plugin = PluginRegistry.get("my-plugin") >>> # List all plugins >>> all_plugins = PluginRegistry.all() >>> # Clear all plugins (for testing) >>> PluginRegistry.clear()
- classmethod register(plugin)[source]¶
Register a diagnostic plugin.
- Parameters:
plugin (DiagnosticPlugin) – Plugin instance to register.
- Raises:
ValueError – If a plugin with the same name is already registered.
Example
>>> PluginRegistry.register(MyPlugin())
- classmethod unregister(name)[source]¶
Unregister a plugin by name.
- Parameters:
name (str) – Name of the plugin to unregister.
- Returns:
True if the plugin was found and removed, False otherwise.
- Return type:
Example
>>> PluginRegistry.unregister("my-plugin") True
- classmethod get(name)[source]¶
Get a plugin by name.
- Parameters:
name (str) – Name of the plugin to retrieve.
- Returns:
Plugin instance if found, None otherwise.
- Return type:
DiagnosticPlugin | None
Example
>>> plugin = PluginRegistry.get("my-plugin") >>> if plugin is not None: ... result = plugin.analyze(...)