MCPcopy Create free account
hub / github.com/StackStorm/st2 / _validate_methods

Function _validate_methods

st2common/st2common/util/loader.py:107–120  ·  view source on GitHub ↗

XXX: This is hacky but we'd like to validate the methods in plugin_impl at least has all the *abstract* methods in plugin_base_class.

(plugin_base_class, plugin_klass)

Source from the content-addressed store, hash-verified

105
106
107def _validate_methods(plugin_base_class, plugin_klass):
108 """
109 XXX: This is hacky but we'd like to validate the methods
110 in plugin_impl at least has all the *abstract* methods in
111 plugin_base_class.
112 """
113 expected_methods = plugin_base_class.__abstractmethods__
114 plugin_methods = _get_plugin_methods(plugin_klass)
115 for method in expected_methods:
116 if method not in plugin_methods:
117 message = (
118 'Class "%s" doesn\'t implement required "%s" method from the base class'
119 )
120 raise IncompatiblePluginException(message % (plugin_klass.__name__, method))
121
122
123def _register_plugin(plugin_base_class, plugin_impl):

Callers 1

_register_pluginFunction · 0.85

Calls 2

_get_plugin_methodsFunction · 0.85

Tested by

no test coverage detected