Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add pydantic v2 compat #73

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/plugins/nonebot_plugin_status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from typing import Any, Dict

from jinja2 import Environment
from nonebot import get_driver
from nonebot.matcher import Matcher
from nonebot import get_plugin_config
from nonebot.permission import SUPERUSER
from nonebot.plugin import PluginMetadata
from jinja2.meta import find_undeclared_variables
Expand Down Expand Up @@ -47,8 +47,7 @@
supported_adapters=None,
)

global_config = get_driver().config
status_config = Config.parse_obj(global_config)
status_config = get_plugin_config(Config)
status_permission = (status_config.server_status_only_superusers or None) and SUPERUSER

_ev = Environment(
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/nonebot_plugin_status/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__author__ = "yanyongyu"


from pydantic import Extra, BaseModel
from pydantic import BaseModel

CPU_TEMPLATE = r"CPU: {{ '%02d' % cpu_usage }}%"
"""Default CPU status template."""
Expand Down Expand Up @@ -45,7 +45,7 @@
"""Default runtime status template."""


class Config(BaseModel, extra=Extra.ignore):
class Config(BaseModel):
server_status_enabled: bool = True
"""Whether to enable the server status commands."""
server_status_truncate: bool = True
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/nonebot_plugin_status/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python = "^3.8"
psutil = "^5.7.2"
Jinja2 = "^3.0.0"
humanize = "^4.0.0"
nonebot2 = "^2.0.0"
nonebot2 = "^2.2.0"
nonebot-adapter-onebot = { version = "^2.0.0-beta.1", optional = true }

[tool.poetry.extras]
Expand Down
Loading