muffin 0.102.2__py3-none-any.whl → 0.102.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- muffin/plugins.py +10 -11
- {muffin-0.102.2.dist-info → muffin-0.102.3.dist-info}/METADATA +1 -1
- {muffin-0.102.2.dist-info → muffin-0.102.3.dist-info}/RECORD +5 -5
- {muffin-0.102.2.dist-info → muffin-0.102.3.dist-info}/WHEEL +0 -0
- {muffin-0.102.2.dist-info → muffin-0.102.3.dist-info}/entry_points.txt +0 -0
muffin/plugins.py
CHANGED
@@ -3,9 +3,8 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
from abc import ABC
|
6
|
-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Mapping, Optional
|
6
|
+
from typing import TYPE_CHECKING, Any, Awaitable, Callable, ClassVar, Mapping, Optional
|
7
7
|
|
8
|
-
from asgi_tools.utils import to_awaitable
|
9
8
|
from modconfig import Config
|
10
9
|
|
11
10
|
from muffin.errors import MuffinError
|
@@ -33,13 +32,13 @@ class BasePlugin(ABC):
|
|
33
32
|
defaults: ClassVar[Mapping[str, Any]] = {"disabled": False}
|
34
33
|
|
35
34
|
# Optional middleware method
|
36
|
-
middleware:
|
35
|
+
middleware: Callable[..., Awaitable]
|
37
36
|
|
38
37
|
# Optional startup method
|
39
|
-
startup:
|
38
|
+
startup: Callable[..., Awaitable]
|
40
39
|
|
41
40
|
# Optional shutdown method
|
42
|
-
shutdown:
|
41
|
+
shutdown: Callable[..., Awaitable]
|
43
42
|
|
44
43
|
# Optional conftest method
|
45
44
|
conftest: Optional[Callable[[], _AsyncGeneratorContextManager]] = None
|
@@ -65,11 +64,11 @@ class BasePlugin(ABC):
|
|
65
64
|
return f"<muffin.Plugin: { self.name }>"
|
66
65
|
|
67
66
|
async def __aenter__(self):
|
68
|
-
if self
|
67
|
+
if hasattr(self, "startup"):
|
69
68
|
await self.startup()
|
70
69
|
|
71
70
|
async def __aexit__(self, exc_type, exc, tb):
|
72
|
-
if self
|
71
|
+
if hasattr(self, "shutdown"):
|
73
72
|
await self.shutdown()
|
74
73
|
|
75
74
|
@property
|
@@ -100,15 +99,15 @@ class BasePlugin(ABC):
|
|
100
99
|
self.__app__ = app
|
101
100
|
|
102
101
|
# Register a middleware
|
103
|
-
if self
|
104
|
-
app.middleware(
|
102
|
+
if hasattr(self, "middleware"):
|
103
|
+
app.middleware(self.middleware)
|
105
104
|
|
106
105
|
# Bind startup
|
107
|
-
if self
|
106
|
+
if hasattr(self, "startup"):
|
108
107
|
app.on_startup(self.startup)
|
109
108
|
|
110
109
|
# Bind shutdown
|
111
|
-
if self
|
110
|
+
if hasattr(self, "shutdown"):
|
112
111
|
app.on_shutdown(self.shutdown)
|
113
112
|
|
114
113
|
return True
|
@@ -4,12 +4,12 @@ muffin/constants.py,sha256=Ga1UJiEdXUk6dIEH_IEVYkFSZxQFPhxie7fCJwQY8V0,71
|
|
4
4
|
muffin/errors.py,sha256=I-vKbMMBiMU07zPdKvoJKqA7s4xYAUA-4oZXrRMRzcM,701
|
5
5
|
muffin/handler.py,sha256=GtIyn-SfWDXsMgJ3GyiJJiWUIezesrFoNVzSHyFI_yA,3736
|
6
6
|
muffin/manage.py,sha256=Lx3WTWVXiSuGnTR8CfNZKyGXxJBM-rHnagVEPxUSxMs,8829
|
7
|
-
muffin/plugins.py,sha256
|
7
|
+
muffin/plugins.py,sha256=-EyGr66DD_3gOzrQo3QSb_22dYgYk04kKsfTsfirld4,3177
|
8
8
|
muffin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
muffin/pytest.py,sha256=51pJ-JJ2vwqiPhR9TPqXvT78X35l3v3oEkN5LBnfY8E,2679
|
10
10
|
muffin/types.py,sha256=wsUj5oAfqSZMoEf-wyFJLBlWa8Mc-eJGqKLr02HxuXE,153
|
11
11
|
muffin/utils.py,sha256=zK_pGeYzWoTsv-4-Rlu6MjOhTEmS46NpprH4MsNRcVw,2899
|
12
|
-
muffin-0.102.
|
13
|
-
muffin-0.102.
|
14
|
-
muffin-0.102.
|
15
|
-
muffin-0.102.
|
12
|
+
muffin-0.102.3.dist-info/METADATA,sha256=GchyqH2hPVxnBrLBWCFSnpu0puJ5-RyAuErDf90o3Uk,11331
|
13
|
+
muffin-0.102.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
14
|
+
muffin-0.102.3.dist-info/entry_points.txt,sha256=GvPS3M-tNVPzhUS5jnUpOmWw2NAqedY34VRCYgPYzlM,84
|
15
|
+
muffin-0.102.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|