nicoddemus on features
Preparing release version 4.2.0 Merge pull request #4696 from n… Merge pull request #4697 from n… (compare)
.__name__
id()
is used
staticmethod
s or classmethod
i think it should work the way you want
plugin_manager.register(MyPlugin)
instead of plugin_manager.register(MyPlugin())
?)
`.register(obj, name=obj.__class__.__name__)
.register(obj, obj.__class__.__name__)
ya... i dont have a registry w names but i kinda just realized that i may want one (because it would allow me to prevent one plugin from raising another plugin's registered check). not too sure about how i'm doing it now anyways because it's in a arbitrary class (as opposed to something aware of the plugin system)
class Check:
IDs: Dict[str, List[Any]]
def __init__(self, *ids: str):
for id_ in ids:
if id_ not in self.IDs:
raise Exception("not registered")
...
@classmethod
def register(cls, registrant: Any, ids: List[str]):
for id_ in ids:
if id_ in cls.IDs:
raise Exception("already registered")
else:
cls.IDs[id_] = registrant
thinking i might move this to my config object (which has the plugin_manager as an attr) so as to be more plugin-aware
self
being a class ref
self
stuff iirc
[nav] In [7]: class C:
...: @classmethod
...: def meth(cls):
...: print(cls)
[nav] In [8]: C.meth()
<class '__main__.C'>