Fixed pydantic deprecation warnings

This commit is contained in:
Alex Root Junior 2023-07-04 00:33:57 +03:00
parent 298b4f0e0d
commit 333f376ad1
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
3 changed files with 5 additions and 3 deletions

View file

@ -85,7 +85,7 @@ class CallbackData(BaseModel):
:return: valid callback data for Telegram Bot API
"""
result = [self.__prefix__]
for key, value in self.dict().items():
for key, value in self.model_dump(mode="json").items():
encoded = self._encode_value(key, value)
if self.__separator__ in encoded:
raise ValueError(

View file

@ -441,7 +441,9 @@ def _apply_entity(entity: MessageEntity, *nodes: NodeType) -> NodeType:
:return:
"""
node_type = NODE_TYPES.get(entity.type, Text)
return node_type(*nodes, **entity.dict(exclude={"type", "offset", "length"}))
return node_type(
*nodes, **entity.model_dump(exclude={"type", "offset", "length"}, warnings=False)
)
def _unparse_entities(

View file

@ -162,7 +162,7 @@ class BaseRequestHandler(ABC):
payload.set_content_disposition("form-data", name="method")
files: Dict[str, InputFile] = {}
for key, value in result.dict().items():
for key, value in result.model_dump(warnings=False).items():
value = bot.session.prepare_value(value, bot=bot, files=files)
if not value:
continue