muffin 0.102.1__tar.gz → 0.102.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: muffin
3
- Version: 0.102.1
3
+ Version: 0.102.3
4
4
  Summary: Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)
5
5
  Home-page: https://github.com/klen/muffin
6
6
  License: MIT
@@ -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: Optional[Callable] = None
35
+ middleware: Callable[..., Awaitable]
37
36
 
38
37
  # Optional startup method
39
- startup: Optional[Callable] = None
38
+ startup: Callable[..., Awaitable]
40
39
 
41
40
  # Optional shutdown method
42
- shutdown: Optional[Callable] = None
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.startup is not None:
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.shutdown is not None:
71
+ if hasattr(self, "shutdown"):
73
72
  await self.shutdown()
74
73
 
75
74
  @property
@@ -80,7 +79,7 @@ class BasePlugin(ABC):
80
79
 
81
80
  return self.__app__
82
81
 
83
- def setup(self, app: Application, *, name: Optional[str] = None, **options) -> bool:
82
+ def setup(self, app: Application, *, name: Optional[str] = None, **options) -> Any:
84
83
  """Bind app and update the plugin's configuration."""
85
84
  # allow to redefine the name for multi plugins with same type
86
85
  self.name = name or self.name
@@ -100,15 +99,15 @@ class BasePlugin(ABC):
100
99
  self.__app__ = app
101
100
 
102
101
  # Register a middleware
103
- if self.middleware:
104
- app.middleware(to_awaitable(self.middleware))
102
+ if hasattr(self, "middleware"):
103
+ app.middleware(self.middleware)
105
104
 
106
105
  # Bind startup
107
- if self.startup:
106
+ if hasattr(self, "startup"):
108
107
  app.on_startup(self.startup)
109
108
 
110
109
  # Bind shutdown
111
- if self.shutdown:
110
+ if hasattr(self, "shutdown"):
112
111
  app.on_shutdown(self.shutdown)
113
112
 
114
113
  return True
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "muffin"
3
- version = "0.102.1"
3
+ version = "0.102.3"
4
4
  description = "Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)"
5
5
  readme = "README.rst"
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes