Skip to content

Commit

Permalink
πŸ”– bump version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CMHopeSunshine committed Mar 25, 2024
1 parent 4f66aaa commit 11697e7
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 140 deletions.
2 changes: 1 addition & 1 deletion nonebot/adapters/dodo/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setup(self) -> None:
"websocket client! "
"DoDo Adapter need a WebSocketClient Driver to work."
)
self.driver.on_startup(self.startup)
self.on_ready(self.startup)
self.driver.on_shutdown(self.shutdown)

async def startup(self) -> None:
Expand Down
3 changes: 1 addition & 2 deletions nonebot/adapters/dodo/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from typing_extensions import override

from nonebot.adapters import Bot as BaseBot
from nonebot.compat import type_validate_python
from nonebot.compat import model_dump, type_validate_python
from nonebot.drivers import Request, Response
from nonebot.message import handle_event

from .compat import model_dump
from .config import BotConfig
from .event import ChannelMessageEvent, Event, PersonalMessageEvent
from .exception import (
Expand Down
30 changes: 1 addition & 29 deletions nonebot/adapters/dodo/compat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from typing import Any, Dict, Literal, Optional, Set, overload
from typing import Literal, overload

from nonebot.compat import PYDANTIC_V2

from pydantic import BaseModel

__all__ = ("model_validator", "field_validator", "GenericModel")

if PYDANTIC_V2:
Expand All @@ -13,19 +11,6 @@
model_validator as model_validator,
)

def model_dump(
model: BaseModel,
include: Optional[Set[str]] = None,
exclude: Optional[Set[str]] = None,
by_alias: bool = False,
exclude_none: bool = False,
) -> Dict[str, Any]:
return model.model_dump(
include=include,
exclude=exclude,
by_alias=by_alias,
exclude_none=exclude_none,
)
else:
from pydantic import root_validator, validator
from pydantic.generics import GenericModel as GenericModel
Expand All @@ -44,16 +29,3 @@ def model_validator(*, mode: Literal["before", "after"] = "after"):
def field_validator(__field, *fields, mode: Literal["before", "after"] = "after"):
return validator(__field, *fields, pre=mode == "before", allow_reuse=True)

def model_dump(
model: BaseModel,
include: Optional[Set[str]] = None,
exclude: Optional[Set[str]] = None,
by_alias: bool = False,
exclude_none: bool = False,
) -> Dict[str, Any]:
return model.dict(
include=include,
exclude=exclude,
by_alias=by_alias,
exclude_none=exclude_none,
)
4 changes: 2 additions & 2 deletions nonebot/adapters/dodo/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from typing_extensions import override

from nonebot.adapters import Event as BaseEvent
from nonebot.compat import PYDANTIC_V2, ConfigDict
from nonebot.compat import PYDANTIC_V2, ConfigDict, model_dump
from nonebot.utils import escape_tag

from pydantic import BaseModel, Field

from .compat import field_validator, model_dump
from .compat import field_validator
from .message import Message
from .models import (
Emoji,
Expand Down
Loading

0 comments on commit 11697e7

Please sign in to comment.