Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 22:49
    RonnyPfannschmidt commented #4702
  • Jan 31 2019 22:25
    nicoddemus opened #4703
  • Jan 31 2019 22:12
    nicoddemus commented #4702
  • Jan 31 2019 21:58
    nicoddemus commented #4701
  • Jan 31 2019 21:22
    RonnyPfannschmidt commented #4701
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:19
    RonnyPfannschmidt commented #4702
  • Jan 31 2019 21:05
    wimglenn commented #4700
  • Jan 31 2019 20:47
    wimglenn commented #4699
  • Jan 31 2019 20:46
    astraw38 opened #4702
  • Jan 31 2019 20:44
    nicoddemus commented #4701
  • Jan 31 2019 19:45
    davidak commented #4701
  • Jan 31 2019 19:10

    nicoddemus on features

    Preparing release version 4.2.0 Merge pull request #4696 from nā€¦ Merge pull request #4697 from nā€¦ (compare)

  • Jan 31 2019 19:10
    nicoddemus closed #4697
  • Jan 31 2019 19:10
    nicoddemus labeled #4701
  • Jan 31 2019 19:10
    nicoddemus labeled #4701
lord_fomo
@goodboy:matrix.org
[m]
no then you couldn't have multiple instances
so i think the key would be that you have to not pass an instance for that to work
i'm not sure multiple instances is a good thing anyway
but that's a deeper discussion to have
if you don't pass an instance, and define your methods as staticmethods or classmethod i think it should work the way you want
David Tucker
@tucked:matrix.org
[m]
oh, is that a supported thing? (you're saying plugin_manager.register(MyPlugin) instead of plugin_manager.register(MyPlugin())?)
1 reply
heh, inteeresting
lord_fomo
@goodboy:matrix.org
[m]
yeah and it makes sense
bc instances can't share the same name or you'd have plugin collisions per name obvs
instances are kind of wacky for this use case to some degree anyway
how often are you really making a plugin that get's instantiated with diff seed data or wtv
i've always thought that support is a little, superfluous
it's been there from the beginning though
i guess the idea is supportingn meta-classes for that case is worse
so yeah, i'd say if you want what you're asking you probably should already have to have a name registry going on for your instances
if you want the class name, then just `.register(obj, name=obj.__class__.__name__)
gack
frickin md
.register(obj, obj.__class__.__name__)
and / or make your own name mapping func for your input object set
with that there should def be no causality dilemma
lord_fomo
@goodboy:matrix.org
[m]
and you're in full control of the name scheme
but yeah the way it is by default makes sense, since ow you get collisions / over-writes per object instance
at least hopefully i'm not confabulating
hmm maybe we removed that actually?
either way as long as your instances are singletons you should be able to do what i showed ^
tucked
@tucked:matrix.org
[m]

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

lord_fomo
@goodboy:matrix.org
[m]
yeah so i can't find any examples of non-instances in tests:
https://github.com/pytest-dev/pluggy/search?q=.register%28
but i do recall having used it, and eyeballing the code there's no reason it won't work.
i'm pretty sure methods should just work as well you'll just get the self being a class ref
but i think that's just python types
that is the symmetry of the self stuff iirc
[nav] In [7]: class C:
         ...:     @classmethod
         ...:     def meth(cls):
         ...:         print(cls)

[nav] In [8]: C.meth()
<class '__main__.C'>
that at least should work
@staticmethod as well
but you can't on plain methods
[nav] In [10]: class C:
          ...:     def meth(cls):
          ...:         print(cls)

[ins] In [11]: C.meth(C)
<class '__main__.C'>
will work, but obviously then you have to bind in the self=C on the hook call
which is pretty ugly
anyway hopefully that didn't confuse you more
but the way it is makes sense
for instances
David Tucker
@tucked:matrix.org
[m]
ya, i agree... (i think you haven't lost me šŸ˜‹ )
lord_fomo
@goodboy:matrix.org
[m]
kk
that's good
šŸ„ā€ā™‚ļø
yeah pluggy is a pretty minimal system
it's basically just a fan-out function call with variable "consumers" of that call
David Tucker
@tucked:matrix.org
[m]
ya... it's pretty great šŸ˜Ž
lord_fomo
@goodboy:matrix.org
[m]
šŸ‘ļø