[Python] How do I find classes that are decorated by a given decorator in Python?

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to do something like SpringBoot @Component scan to search for classes that are decorated with Temporal @worfklow.defn and @activity.defn so I can automatically register them to the worker without explicit plumbing.

    Do Python decorators provide a facility for a lookup like that?

    importlib.find_all_classes_decorated_by(workflow.defn)

    Continue reading...

Compartilhe esta Página