-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
122 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Literal, overload | ||
|
||
from nonebot.compat import PYDANTIC_V2 | ||
|
||
__all__ = ("model_validator",) | ||
|
||
|
||
if PYDANTIC_V2: | ||
from pydantic import model_validator as model_validator | ||
else: | ||
from pydantic import root_validator | ||
|
||
@overload | ||
def model_validator(*, mode: Literal["before"]): | ||
... | ||
|
||
@overload | ||
def model_validator(*, mode: Literal["after"]): | ||
... | ||
|
||
def model_validator(*, mode: Literal["before", "after"]): | ||
return root_validator(pre=mode == "before", allow_reuse=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.