File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 22
33import sys
44from itertools import repeat
5- from typing import Any , cast
65from dataclasses import dataclass
76from operator import methodcaller
7+ from typing import Any , Type , cast
88from inspect import Parameter , isclass
99
1010from pydantic .fields import FieldInfo
@@ -166,7 +166,7 @@ def _check_param(
166166 if depends_inner is not None :
167167 dependency = compile_dependency (depends_inner .dependency , option )
168168 elif all (map (isclass , models )) and all (map (issubclass , models , repeat (Model ))):
169- models = cast (Tuple [Model , ...], models )
169+ models = cast (Tuple [Type [ Model ] , ...], models )
170170 dependency = compile_dependency (
171171 select (* models ).where (
172172 * (
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import asyncio
34from typing import cast
45
56from alembic import context
67from sqlalchemy import Connection
7- from sqlalchemy .util import await_fallback
8+ from sqlalchemy .util import await_only
89from sqlalchemy .ext .asyncio import AsyncEngine
910
1011from nonebot_plugin_orm .env import no_drop_table
@@ -81,4 +82,9 @@ async def run_migrations_online() -> None:
8182if context .is_offline_mode ():
8283 run_migrations_offline ()
8384else :
84- await_fallback (run_migrations_online ())
85+ coro = run_migrations_online ()
86+
87+ try :
88+ asyncio .run (coro )
89+ except RuntimeError :
90+ await_only (coro )
Original file line number Diff line number Diff line change 22
33import asyncio
44from typing import cast
5+ from contextlib import suppress
56
67from alembic import context
7- from sqlalchemy .util import await_fallback
8+ from sqlalchemy .util import await_only
89from sqlalchemy .ext .asyncio import AsyncEngine , AsyncConnection
910from sqlalchemy import MetaData , Connection , TwoPhaseTransaction
1011
@@ -124,4 +125,9 @@ async def run_migrations_online() -> None:
124125if context .is_offline_mode ():
125126 run_migrations_offline ()
126127else :
127- await_fallback (run_migrations_online ())
128+ coro = run_migrations_online ()
129+
130+ with suppress (RuntimeError ):
131+ asyncio .run (coro )
132+
133+ await_only (coro )
You can’t perform that action at this time.
0 commit comments