Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
hookery
Minimally invasive hooks with no metaclasses and no class decorators since v5.0.0
.
v3.10.1
status is Beta
.v5.x
status is Pre-Alpha
.I use v3.10.1
(https://pypi.org/project/hookery/3.10.1/) in production for work.
This document is for v5.x
which is NOT production-ready yet.
.. code-block:: shell
pip install hookery==3.10.1
.. code-block:: python
from hookery import Hook, hooks
class Profile:
on_activated = Hook()
@on_activated
def log_activation(self):
print(f"Activating {self}")
def activate(self):
hooks.trigger(self.on_activated)
class WarehouseProfile(Profile):
@Profile.on_activated
def log_activation(self):
print(f"Warehouse profile {self} is being activated")
@Profile.on_activated
def another_handler(self):
print(f"This will also be printed")
The dummy example above demonstrates that:
log_activation
in child class does not override a handler with the same name
in parent class... code-block:: python
>>> profile = WarehouseProfile()
>>> profile.activate()
Activating <__main__.WarehouseProfile object at 0x103ee66d8>
Warehouse profile <__main__.WarehouseProfile object at 0x103ee66d8> is being activated
This will also be printed
@classmethod
's and @staticmethod
's cannot be registered as handlers because hooks apply to instances of
a class, not the class itself.FAQs
Trivial, primitive, naive, and optimistic hooks in Python 3.6+
We found that hookery demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.