-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#102] initial upgrade to pydantic v2
- Loading branch information
Showing
15 changed files
with
192 additions
and
132 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
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
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 |
---|---|---|
@@ -1,32 +1,44 @@ | ||
from pydantic import BaseModel | ||
from pydantic import BaseModel, RootModel | ||
from hsclient import Token | ||
|
||
# typing imports | ||
from typing import Tuple, Union | ||
from typing import Tuple, Union, Literal, Any, Optional | ||
|
||
|
||
class OAuthFile(BaseModel): | ||
__root__: Tuple[Token, str] | ||
OAuthFile = RootModel[Tuple[Token, str]] | ||
|
||
def dict( | ||
self, | ||
*, | ||
include: Union["AbstractSetIntStr", "MappingIntStrAny"] = None, | ||
exclude: Union["AbstractSetIntStr", "MappingIntStrAny"] = None, | ||
by_alias: bool = False, | ||
skip_defaults: bool = None, | ||
exclude_unset: bool = False, | ||
exclude_defaults: bool = False, | ||
exclude_none: bool = False | ||
) -> "DictStrAny": | ||
d = super().dict( | ||
include=include, | ||
exclude=exclude, | ||
by_alias=by_alias, | ||
skip_defaults=skip_defaults, | ||
exclude_unset=exclude_unset, | ||
exclude_defaults=exclude_defaults, | ||
exclude_none=exclude_none, | ||
) | ||
# drop __root__, return only inner model | ||
return d["__root__"] | ||
# TODO: cleanup - also fix the imports above | ||
# class OAuthFile(RootModel, BaseModel): | ||
# root: Tuple[Token, str] | ||
# def model_dump( | ||
# self, | ||
# *, | ||
# mode: Literal['json', 'python'] | str = 'python', | ||
# include: "IncEx" = None, | ||
# exclude: "IncEx" = None, | ||
# context: dict[str, Any] | None = None, | ||
# by_alias: bool = False, | ||
# exclude_unset: bool = False, | ||
# exclude_defaults: bool = False, | ||
# exclude_none: bool = False, | ||
# round_trip: bool = False, | ||
# warnings: bool | Literal['none', 'warn', 'error'] = True, | ||
# serialize_as_any: bool = False, | ||
# ) -> dict[str, Any]: | ||
# d = super().model_dump( | ||
# mode=mode, | ||
# include=include, | ||
# exclude=exclude, | ||
# context=context, | ||
# by_alias=by_alias, | ||
# exclude_unset=exclude_unset, | ||
# exclude_defaults=exclude_defaults, | ||
# exclude_none=exclude_none, | ||
# round_trip=round_trip, | ||
# warnings=warnings, | ||
# serialize_as_any=serialize_as_any, | ||
# ) | ||
# # drop __root__, return only inner model | ||
# print(d) | ||
# root, _ = d | ||
# return self.root |
Oops, something went wrong.