|
@@ -1,4 +1,5 @@
|
|
from typing import Type, TypeVar
|
|
from typing import Type, TypeVar
|
|
|
|
+import dataclasses
|
|
|
|
|
|
from ..types import Context
|
|
from ..types import Context
|
|
from ..injection import Data
|
|
from ..injection import Data
|
|
@@ -10,6 +11,9 @@ T = TypeVar("T")
|
|
|
|
|
|
|
|
|
|
def initialize_data(cls: Type[T]) -> Type[T]:
|
|
def initialize_data(cls: Type[T]) -> Type[T]:
|
|
|
|
+ if not dataclasses.is_dataclass(cls):
|
|
|
|
+ cls = dataclasses.dataclass(cls)
|
|
|
|
+
|
|
@on_startup
|
|
@on_startup
|
|
async def setup_my_counter(context: Context):
|
|
async def setup_my_counter(context: Context):
|
|
async with context.database() as db:
|
|
async with context.database() as db:
|