equal
deleted
inserted
replaced
|
1 # misc.py - Various Interface that did not deserve a dedicated module (yet) |
|
2 # |
|
3 # Copyright 2025 Octobus, contact@octobus.net |
|
4 from __future__ import annotations |
|
5 |
|
6 import abc |
|
7 |
|
8 from typing import ( |
|
9 Callable, |
|
10 List, |
|
11 Protocol, |
|
12 ) |
|
13 |
|
14 |
|
15 class IHooks(Protocol): |
|
16 """A collection of hook functions that can be used to extend a |
|
17 function's behavior. Hooks are called in lexicographic order, |
|
18 based on the names of their sources.""" |
|
19 |
|
20 @abc.abstractmethod |
|
21 def add(self, source: bytes, hook: Callable): |
|
22 ... |
|
23 |
|
24 @abc.abstractmethod |
|
25 def __call__(self, *args) -> List: |
|
26 ... |