mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #14976 from xiaket/devel
use __mro__ for plugin loading when we search for its base class.
This commit is contained in:
commit
407f8f934e
1 changed files with 7 additions and 2 deletions
|
@ -329,7 +329,12 @@ class PluginLoader:
|
||||||
obj = getattr(self._module_cache[path], self.class_name)
|
obj = getattr(self._module_cache[path], self.class_name)
|
||||||
else:
|
else:
|
||||||
obj = getattr(self._module_cache[path], self.class_name)(*args, **kwargs)
|
obj = getattr(self._module_cache[path], self.class_name)(*args, **kwargs)
|
||||||
if self.base_class and self.base_class not in [base.__name__ for base in obj.__class__.__bases__]:
|
if self.base_class:
|
||||||
|
# The import path is hardcoded and should be the right place,
|
||||||
|
# so we are not expecting an ImportError.
|
||||||
|
module = __import__(self.package, fromlist=[self.base_class])
|
||||||
|
# Check whether this obj has the required base class.
|
||||||
|
if not issubclass(obj.__class__, getattr(module, self.base_class, None)):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|
Loading…
Add table
Reference in a new issue