From f363ff51351811a5deafc6bb9917d50a4287f68e Mon Sep 17 00:00:00 2001 From: huangwenlong06 Date: Wed, 4 Sep 2024 11:56:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=98=AFpydantic=20v2?= =?UTF-8?q?=E5=8F=88=E6=B2=A1=E6=9C=89=E5=AE=89=E8=A3=85pydantic-settings?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E7=A4=BA=E7=94=A8=E6=88=B7=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 4 ++-- pyproject.toml | 1 + src/nonebot_plugin_access_control/config.py | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 5d7bf1f..58ccd88 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1790,7 +1790,7 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" name = "pydantic-settings" version = "2.4.0" description = "Settings management using Pydantic" -optional = true +optional = false python-versions = ">=3.8" files = [ {file = "pydantic_settings-2.4.0-py3-none-any.whl", hash = "sha256:bb6849dc067f1687574c12a639e231f3a6feeed0a12d710c1382045c5db1c315"}, @@ -2898,4 +2898,4 @@ migrate = [] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "159059525df8114c5c3777836b8261337f82ad705329e23d6ed585fb6a9d55f5" +content-hash = "7e18f2545f2bce7cb2ff5e24e49ef19b2ba3741c562410b74f3d24abc25be999" diff --git a/pyproject.toml b/pyproject.toml index e876dd8..f5f8498 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ nonebug = "^0.3.5" pytest = "^7.4.3" pytest-asyncio = "^0.21.1" pytest-cov = "^4.1.0" +pydantic-settings = "^2.4.0" [tool.black] diff --git a/src/nonebot_plugin_access_control/config.py b/src/nonebot_plugin_access_control/config.py index c4cbe28..a40002e 100644 --- a/src/nonebot_plugin_access_control/config.py +++ b/src/nonebot_plugin_access_control/config.py @@ -6,7 +6,12 @@ try: from pydantic_settings import BaseSettings except ImportError: - from pydantic import BaseSettings + try: + from pydantic import BaseSettings + except ImportError as e: + raise ImportError( + "如果你正在使用pydantic v2,请手动安装pydantic-settings" + ) from e class Config(BaseSettings):