Skip to content

Commit

Permalink
✨ Feature: 兼容 pydantic v2 (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ju4tCode <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2024
1 parent e15f6c2 commit 31ecc7b
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 61 deletions.
5 changes: 2 additions & 3 deletions nonebot_plugin_apscheduler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging

from nonebot import get_driver
from nonebot.plugin import PluginMetadata
from nonebot.log import LoguruHandler, logger
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from nonebot.plugin import PluginMetadata, get_plugin_config

from .config import Config

Expand All @@ -23,8 +23,7 @@


driver = get_driver()
global_config = driver.config
plugin_config = Config(**global_config.dict())
plugin_config = get_plugin_config(Config)

scheduler = AsyncIOScheduler()
scheduler.configure(plugin_config.apscheduler_config)
Expand Down
7 changes: 2 additions & 5 deletions nonebot_plugin_apscheduler/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from pydantic import Field, BaseSettings
from pydantic import Field, BaseModel


class Config(BaseSettings):
class Config(BaseModel):
apscheduler_autostart: bool = True
apscheduler_log_level: int = 30
apscheduler_config: dict = Field(
default_factory=lambda: {"apscheduler.timezone": "Asia/Shanghai"}
)

class Config:
extra = "ignore"
Loading

0 comments on commit 31ecc7b

Please sign in to comment.