diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd59492..a4a9366 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,20 +7,20 @@ ci: autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks" repos: - repo: https://github.com/hadialqattan/pycln - rev: v2.4.0 + rev: v2.6.0 hooks: - id: pycln args: [--config, pyproject.toml] stages: [pre-commit] - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 9.0.2 hooks: - id: isort stages: [pre-commit] - - repo: https://github.com/psf/black - rev: 24.10.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.10.0 hooks: - id: black stages: [pre-commit] diff --git a/nonebot_plugin_orm/__init__.py b/nonebot_plugin_orm/__init__.py index f9c9cf6..19eb230 100644 --- a/nonebot_plugin_orm/__init__.py +++ b/nonebot_plugin_orm/__init__.py @@ -2,22 +2,25 @@ import logging from argparse import Namespace -from functools import wraps, lru_cache +from functools import cache, wraps +from collections.abc import Generator +from contextlib import contextmanager from typing_extensions import Any, Annotated import click from nonebot.rule import Rule +from alembic.op import get_bind import sqlalchemy.ext.asyncio as sa_async from nonebot.permission import Permission -from sqlalchemy.util import greenlet_spawn from sqlalchemy import URL, Table, MetaData +from sqlalchemy.util import greenlet_spawn from nonebot.message import run_postprocessor from nonebot.params import Depends, DefaultParam from nonebot.plugin import Plugin, PluginMetadata from sqlalchemy.log import Identified, _qual_logger_name_for_cls from nonebot.matcher import Matcher, current_event, current_matcher -from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine from nonebot import logger, require, get_driver, get_plugin_by_module_name +from sqlalchemy.ext.asyncio import AsyncEngine, AsyncConnection, create_async_engine from . import migrate from .param import ORMParam @@ -25,7 +28,7 @@ from .utils import LoguruHandler, StreamToLogger, coroutine, get_subclasses require("nonebot_plugin_localstore") -from nonebot_plugin_localstore import get_data_dir +from nonebot_plugin_localstore import get_data_dir, get_plugin_data_dir __all__ = ( # __init__ @@ -60,8 +63,16 @@ _session_factory: sa_async.async_sessionmaker[sa_async.AsyncSession] _scoped_sessions: sa_async.async_scoped_session[sa_async.AsyncSession] -_data_dir = get_data_dir("nonebot_plugin_orm") -if (_deprecated_data_dir := get_data_dir(None) / "nonebot-plugin-orm").exists(): +_data_dir = get_plugin_data_dir() +if ( + _deprecated_data_dir := get_data_dir(None) / "nonebot-plugin-orm" +).exists() and next(_deprecated_data_dir.iterdir(), None): + if next(_data_dir.iterdir(), None): + raise RuntimeError( + "无法自动迁移数据目录, 请手动将 " + f"{_deprecated_data_dir} 中的数据移动到 {_data_dir} 中." + ) + _data_dir.rmdir() _deprecated_data_dir.rename(_data_dir) _driver = get_driver() @@ -93,22 +104,6 @@ async def init_orm() -> None: await greenlet_spawn(migrate.sync, alembic_config) -def _init_orm(): - global _session_factory, _scoped_sessions - - _init_engines() - _init_table() - _session_factory = sa_async.async_sessionmaker( - _engines[""], binds=_binds, **plugin_config.sqlalchemy_session_options - ) - _scoped_sessions = sa_async.async_scoped_session( - _session_factory, - lambda: (id(current_event.get(None)), current_matcher.get(None)), - ) - - run_postprocessor(_scoped_sessions.remove) - - def get_session(**local_kw: Any) -> sa_async.AsyncSession: try: return _session_factory(**local_kw) @@ -141,6 +136,26 @@ def get_scoped_session() -> sa_async.async_scoped_session[sa_async.AsyncSession] ] +@contextmanager +def _patch_migrate_session() -> Generator[None, Any, None]: + global _session_factory, _scoped_sessions + + session_factory, scoped_sessions = _session_factory, _scoped_sessions + + _session_factory = sa_async.async_sessionmaker( + AsyncConnection._retrieve_proxy_for_target(get_bind()), + **plugin_config.sqlalchemy_session_options, + ) + _scoped_sessions = sa_async.async_scoped_session( + _session_factory, + lambda: (id(current_event.get(None)), current_matcher.get(None)), + ) + + yield + + _session_factory, _scoped_sessions = session_factory, scoped_sessions + + def _create_engine(engine: str | URL | dict[str, Any] | AsyncEngine) -> AsyncEngine: if isinstance(engine, AsyncEngine): return engine @@ -192,7 +207,7 @@ def _init_table(): _binds = {} _plugins = {} - _get_plugin_by_module_name = lru_cache(None)(get_plugin_by_module_name) + _get_plugin_by_module_name = cache(get_plugin_by_module_name) for model in set(get_subclasses(Model)): table: Table | None = getattr(model, "__table__", None) @@ -206,6 +221,22 @@ def _init_table(): table.to_metadata(_metadatas.get(bind_key, _metadatas[""])) +def _init_orm(): + global _session_factory, _scoped_sessions + + _init_engines() + _init_table() + _session_factory = sa_async.async_sessionmaker( + _engines[""], binds=_binds, **plugin_config.sqlalchemy_session_options + ) + _scoped_sessions = sa_async.async_scoped_session( + _session_factory, + lambda: (id(current_event.get(None)), current_matcher.get(None)), + ) + + run_postprocessor(_scoped_sessions.remove) + + def _init_logger(): handler = LoguruHandler() logging.getLogger("alembic").addHandler(handler) diff --git a/nonebot_plugin_orm/__main__.py b/nonebot_plugin_orm/__main__.py index 777d254..dd3c07e 100644 --- a/nonebot_plugin_orm/__main__.py +++ b/nonebot_plugin_orm/__main__.py @@ -69,7 +69,7 @@ def orm(ctx: click.Context, config: Path, name: str, **_) -> None: def update_cmd_opts( - f: Callable[Concatenate[AlembicConfig, _P], _R] + f: Callable[Concatenate[AlembicConfig, _P], _R], ) -> Callable[_P, _R]: @wraps(f) @click.pass_context diff --git a/nonebot_plugin_orm/migrate.py b/nonebot_plugin_orm/migrate.py index a4ab6a9..cf03c84 100644 --- a/nonebot_plugin_orm/migrate.py +++ b/nonebot_plugin_orm/migrate.py @@ -22,11 +22,13 @@ from sqlalchemy.util import asbool from nonebot import logger, get_plugin from sqlalchemy import MetaData, Connection +from nonebot.matcher import current_matcher from alembic.util.editor import open_in_editor from alembic.script import Script, ScriptDirectory from alembic.util.langhelpers import rev_id as _rev_id from alembic.operations.ops import UpgradeOps, DowngradeOps from alembic.migration import StampStep, RevisionStep, MigrationContext +from sqlalchemy.ext.asyncio import AsyncConnection, async_sessionmaker from alembic.runtime.environment import EnvironmentContext, ProcessRevisionDirectiveFn from alembic.autogenerate.api import ( RevisionContext, @@ -121,21 +123,17 @@ def __init__( stdout, cmd_opts, { - **{ - "script_location": script_location, - "prepend_sys_path": ".", - "revision_environment": "true", - "version_path_separator": "os", - }, - **config_args, - }, + "script_location": script_location, + "prepend_sys_path": ".", + "revision_environment": "true", + "version_path_separator": "os", + } + | dict(config_args), { - **{ - "engines": _engines, - "metadatas": _metadatas, - }, - **attributes, - }, + "engines": _engines, + "metadatas": _metadatas, + } + | attributes, ) self._init_post_write_hooks() @@ -646,7 +644,11 @@ def upgrade( @return_progressbar def upgrade(rev, _) -> Iterable[StampStep | RevisionStep]: - yield from script._upgrade_revs(revision, rev) + from . import _patch_migrate_session + + with _patch_migrate_session(): + yield from script._upgrade_revs(revision, rev) + _move_run_scripts(config, script, revision) with EnvironmentContext( @@ -691,7 +693,11 @@ def downgrade( @return_progressbar def downgrade(rev, _) -> Iterable[StampStep | RevisionStep]: - yield from script._downgrade_revs(revision, rev) + from . import _patch_migrate_session + + with _patch_migrate_session(): + yield from script._downgrade_revs(revision, rev) + _move_run_scripts(config, script, revision) with EnvironmentContext( diff --git a/nonebot_plugin_orm/model.py b/nonebot_plugin_orm/model.py index 366e9be..7d0d171 100644 --- a/nonebot_plugin_orm/model.py +++ b/nonebot_plugin_orm/model.py @@ -63,7 +63,7 @@ def _setup_di(cls: type[Model]) -> None: # Check if the attribute is both a dependent and a mapped column depends_inner = None if get_origin(type_annotation) is Annotated: - (type_annotation, *extra_args) = get_args(type_annotation) + type_annotation, *extra_args = get_args(type_annotation) depends_inner = next( (x for x in extra_args if isinstance(x, DependsInner)), None ) diff --git a/nonebot_plugin_orm/templates/generic/env.py b/nonebot_plugin_orm/templates/generic/env.py index edd5fee..f143c79 100644 --- a/nonebot_plugin_orm/templates/generic/env.py +++ b/nonebot_plugin_orm/templates/generic/env.py @@ -1,7 +1,7 @@ from __future__ import annotations import asyncio -from typing import cast +from typing import Any, cast from alembic import context from sqlalchemy import Connection @@ -36,34 +36,26 @@ def run_migrations_offline() -> None: 在这里调用 context.execute() 会将给定的字符串写入到脚本输出. """ - context.configure( - **{ - **dict( - url=engine.url, - dialect_opts={"paramstyle": "named"}, - target_metadata=target_metadata, - literal_binds=True, - ), - **plugin_config.alembic_context, - } - ) + opts: dict[str, Any] = { + "url": engine.url, + "dialect_opts": {"paramstyle": "named"}, + "target_metadata": target_metadata, + "literal_binds": True, + } | plugin_config.alembic_context + context.configure(**opts) with context.begin_transaction(): context.run_migrations() def do_run_migrations(connection: Connection) -> None: - context.configure( - **{ - **dict( - connection=connection, - render_as_batch=True, - target_metadata=target_metadata, - include_object=no_drop_table, - ), - **plugin_config.alembic_context, - } - ) + opts: dict[str, Any] = { + "connection": connection, + "render_as_batch": True, + "target_metadata": target_metadata, + "include_object": no_drop_table, + } | plugin_config.alembic_context + context.configure(**opts) with context.begin_transaction(): context.run_migrations() @@ -78,6 +70,8 @@ async def run_migrations_online() -> None: async with engine.connect() as connection: await connection.run_sync(do_run_migrations) + await engine.dispose() + if context.is_offline_mode(): run_migrations_offline() diff --git a/nonebot_plugin_orm/templates/multidb/env.py b/nonebot_plugin_orm/templates/multidb/env.py index deb242e..b962aba 100644 --- a/nonebot_plugin_orm/templates/multidb/env.py +++ b/nonebot_plugin_orm/templates/multidb/env.py @@ -1,12 +1,12 @@ from __future__ import annotations import asyncio -from typing import cast +from typing import Any, cast from alembic import context from sqlalchemy.util import await_only -from sqlalchemy.ext.asyncio import AsyncEngine, AsyncConnection from sqlalchemy import MetaData, Connection, TwoPhaseTransaction +from sqlalchemy.ext.asyncio import AsyncEngine, AsyncConnection from nonebot_plugin_orm.env import no_drop_table from nonebot_plugin_orm import AlembicConfig, plugin_config @@ -51,37 +51,31 @@ def run_migrations_offline() -> None: config.print_stdout(f"迁移数据库 {name or ''} 中 ...") file_ = f"{name}.sql" with open(file_, "w") as buffer: - context.configure( - **{ - **dict( - url=engine.url, - dialect_opts={"paramstyle": "named"}, - output_buffer=buffer, - target_metadata=target_metadatas["name"], - literal_binds=True, - ), - **plugin_config.alembic_context, - } - ) + opts: dict[str, Any] = { + "url": engine.url, + "dialect_opts": {"paramstyle": "named"}, + "output_buffer": buffer, + "target_metadata": target_metadatas[name], + "literal_binds": True, + } | plugin_config.alembic_context + context.configure(**opts) + with context.begin_transaction(): context.run_migrations(name=name) config.print_stdout(f"将输出写入到 {file_}") def do_run_migrations(conn: Connection, name: str, metadata: MetaData) -> None: - context.configure( - **{ - **dict( - connection=conn, - render_as_batch=True, - target_metadata=metadata, - include_object=no_drop_table, - upgrade_token=f"{name}_upgrades", - downgrade_token=f"{name}_downgrades", - ), - **plugin_config.alembic_context, - } - ) + opts: dict[str, Any] = { + "connection": conn, + "render_as_batch": True, + "target_metadata": metadata, + "include_object": no_drop_table, + "upgrade_token": f"{name}_upgrades", + "downgrade_token": f"{name}_downgrades", + } | plugin_config.alembic_context + context.configure(**opts) + context.run_migrations(name=name) @@ -119,6 +113,7 @@ async def run_migrations_online() -> None: raise finally: await asyncio.gather(*(conn.close() for conn in conns.values())) + await asyncio.gather(*(engine.dispose() for engine in engines.values())) if context.is_offline_mode(): diff --git a/pdm.lock b/pdm.lock index 1991ef8..3cb50e3 100644 --- a/pdm.lock +++ b/pdm.lock @@ -4,8 +4,8 @@ [metadata] groups = ["default", "dev"] strategy = ["inherit_metadata"] -lock_version = "4.5.0" -content_hash = "sha256:dfa963111db2582beac804684ef8cfb312f82bdfaa31eb636ecde0e7f400090d" +lock_version = "4.5.1" +content_hash = "sha256:3f291e32b43be79fe10c5885bf90ce50b9cc10aac63b56d53d15b92df190f369" [[metadata.targets]] requires_python = "~=3.9" @@ -1257,6 +1257,62 @@ files = [ {file = "sqlalchemy-2.0.41.tar.gz", hash = "sha256:edba70118c4be3c2b1f90754d308d0b79c6fe2c0fdc52d8ddf603916f83f4db9"}, ] +[[package]] +name = "sqlalchemy" +version = "2.0.41" +extras = ["asyncio"] +requires_python = ">=3.7" +summary = "Database Abstraction Library" +groups = ["default"] +dependencies = [ + "greenlet>=1", + "sqlalchemy==2.0.41", +] +files = [ + {file = "sqlalchemy-2.0.41-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b1f09b6821406ea1f94053f346f28f8215e293344209129a9c0fcc3578598d7b"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1936af879e3db023601196a1684d28e12f19ccf93af01bf3280a3262c4b6b4e5"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b2ac41acfc8d965fb0c464eb8f44995770239668956dc4cdf502d1b1ffe0d747"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81c24e0c0fde47a9723c81d5806569cddef103aebbf79dbc9fcbb617153dea30"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:23a8825495d8b195c4aa9ff1c430c28f2c821e8c5e2d98089228af887e5d7e29"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:60c578c45c949f909a4026b7807044e7e564adf793537fc762b2489d522f3d11"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-win32.whl", hash = "sha256:118c16cd3f1b00c76d69343e38602006c9cfb9998fa4f798606d28d63f23beda"}, + {file = "sqlalchemy-2.0.41-cp310-cp310-win_amd64.whl", hash = "sha256:7492967c3386df69f80cf67efd665c0f667cee67032090fe01d7d74b0e19bb08"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6375cd674fe82d7aa9816d1cb96ec592bac1726c11e0cafbf40eeee9a4516b5f"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9f8c9fdd15a55d9465e590a402f42082705d66b05afc3ffd2d2eb3c6ba919560"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:32f9dc8c44acdee06c8fc6440db9eae8b4af8b01e4b1aee7bdd7241c22edff4f"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90c11ceb9a1f482c752a71f203a81858625d8df5746d787a4786bca4ffdf71c6"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:911cc493ebd60de5f285bcae0491a60b4f2a9f0f5c270edd1c4dbaef7a38fc04"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:03968a349db483936c249f4d9cd14ff2c296adfa1290b660ba6516f973139582"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-win32.whl", hash = "sha256:293cd444d82b18da48c9f71cd7005844dbbd06ca19be1ccf6779154439eec0b8"}, + {file = "sqlalchemy-2.0.41-cp311-cp311-win_amd64.whl", hash = "sha256:3d3549fc3e40667ec7199033a4e40a2f669898a00a7b18a931d3efb4c7900504"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:81f413674d85cfd0dfcd6512e10e0f33c19c21860342a4890c3a2b59479929f9"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:598d9ebc1e796431bbd068e41e4de4dc34312b7aa3292571bb3674a0cb415dd1"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a104c5694dfd2d864a6f91b0956eb5d5883234119cb40010115fd45a16da5e70"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6145afea51ff0af7f2564a05fa95eb46f542919e6523729663a5d285ecb3cf5e"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b46fa6eae1cd1c20e6e6f44e19984d438b6b2d8616d21d783d150df714f44078"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41836fe661cc98abfae476e14ba1906220f92c4e528771a8a3ae6a151242d2ae"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-win32.whl", hash = "sha256:a8808d5cf866c781150d36a3c8eb3adccfa41a8105d031bf27e92c251e3969d6"}, + {file = "sqlalchemy-2.0.41-cp312-cp312-win_amd64.whl", hash = "sha256:5b14e97886199c1f52c14629c11d90c11fbb09e9334fa7bb5f6d068d9ced0ce0"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:4eeb195cdedaf17aab6b247894ff2734dcead6c08f748e617bfe05bd5a218443"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d4ae769b9c1c7757e4ccce94b0641bc203bbdf43ba7a2413ab2523d8d047d8dc"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a62448526dd9ed3e3beedc93df9bb6b55a436ed1474db31a2af13b313a70a7e1"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc56c9788617b8964ad02e8fcfeed4001c1f8ba91a9e1f31483c0dffb207002a"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:c153265408d18de4cc5ded1941dcd8315894572cddd3c58df5d5b5705b3fa28d"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f67766965996e63bb46cfbf2ce5355fc32d9dd3b8ad7e536a920ff9ee422e23"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-win32.whl", hash = "sha256:bfc9064f6658a3d1cadeaa0ba07570b83ce6801a1314985bf98ec9b95d74e15f"}, + {file = "sqlalchemy-2.0.41-cp313-cp313-win_amd64.whl", hash = "sha256:82ca366a844eb551daff9d2e6e7a9e5e76d2612c8564f58db6c19a726869c1df"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9a420a91913092d1e20c86a2f5f1fc85c1a8924dbcaf5e0586df8aceb09c9cc2"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:906e6b0d7d452e9a98e5ab8507c0da791856b2380fdee61b765632bb8698026f"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a373a400f3e9bac95ba2a06372c4fd1412a7cee53c37fc6c05f829bf672b8769"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:087b6b52de812741c27231b5a3586384d60c353fbd0e2f81405a814b5591dc8b"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:34ea30ab3ec98355235972dadc497bb659cc75f8292b760394824fab9cf39826"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8280856dd7c6a68ab3a164b4a4b1c51f7691f6d04af4d4ca23d6ecf2261b7923"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-win32.whl", hash = "sha256:b50eab9994d64f4a823ff99a0ed28a6903224ddbe7fef56a6dd865eec9243440"}, + {file = "sqlalchemy-2.0.41-cp39-cp39-win_amd64.whl", hash = "sha256:5e22575d169529ac3e0a120cf050ec9daa94b6a9597993d1702884f6954a7d71"}, + {file = "sqlalchemy-2.0.41-py3-none-any.whl", hash = "sha256:57df5dc6fdb5ed1a88a1ed2195fd31927e705cad62dedd86b46972752a80f576"}, + {file = "sqlalchemy-2.0.41.tar.gz", hash = "sha256:edba70118c4be3c2b1f90754d308d0b79c6fe2c0fdc52d8ddf603916f83f4db9"}, +] + [[package]] name = "tomli" version = "2.2.1" diff --git a/pyproject.toml b/pyproject.toml index 9d793e5..6aa0b77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nonebot-plugin-orm" -version = "0.7.7" +version = "0.8.4" description = "SQLAlchemy ORM support for nonebot" authors = [ { name = "yanyongyu", email = "yyy@nonebot.dev" }, @@ -13,7 +13,7 @@ dependencies = [ "importlib-resources>=5.12; python_version < \"3.12\"", "nonebot-plugin-localstore~=0.7", "nonebot2~=2.4", - "sqlalchemy~=2.0", + "sqlalchemy[asyncio]~=2.0", "typing-extensions~=4.13", ] requires-python = ">=3.9,<4.0" @@ -27,7 +27,6 @@ repository = "https://github.com/nonebot/plugin-orm" documentation = "https://github.com/nonebot/plugin-orm" [project.optional-dependencies] -default = ["sqlalchemy[aiosqlite]"] mysql = ["sqlalchemy[aiomysql]"] asyncmy = ["sqlalchemy[asyncmy]"] aiomysql = ["sqlalchemy[aiomysql]"] @@ -54,7 +53,7 @@ dev = [ "nonemoji~=0.1", "pre-commit~=3.5", "pycln~=2.4", - "sqlalchemy[aiosqlite]", + "sqlalchemy[aiosqlite]~=2.0", "typing-extensions~=4.9", ]