fixed docs, added to_python() pydantic alternative

This commit is contained in:
DanZ-ix 2024-05-06 11:45:06 +03:00
parent 4591906209
commit c45586f304
2 changed files with 10 additions and 5 deletions

View file

@ -1 +1 @@
Added message serialisation and deserialization block in 2.x -> 3.x migration guide
Added telegram objects transformation block in 2.x -> 3.x migration guide

View file

@ -151,9 +151,14 @@ Telegram API Server
- The constant `aiogram.bot.api.TELEGRAM_PRODUCTION` has been moved to `aiogram.client.telegram.PRODUCTION`.
Message serialisation and deserialization
Telegram objects transformation (to dict, to json, from json)
===========================================
- Method :class:`Message.to_object()` and :class:`Message.to_json()` have been removed. :class:`Message.model_dump()` should be used
instead of :class:`Message.to_object()` and :class:`Message.model_dump_json()` instead of :class:`Message.to_json` due
to use of `pydantic <https://docs.pydantic.dev/>`_ models.
- Methods :class:`TelegramObject.to_object()`, :class:`TelegramObject.to_json()` and :class:`TelegramObject.to_python()`
have been removed due to the use of `pydantic <https://docs.pydantic.dev/>`_ models.
- :class:`TelegramObject.model_validate_json()` should be used instead of :class:`TelegramObject.to_object()`
(`Read more <https://docs.pydantic.dev/2.7/api/base_model/#pydantic.BaseModel.model_validate_json>`_)
- :class:`TelegramObject.model_dump_json()` should be used instead of :class:`TelegramObject.as_json()`
(`Read more <https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_dump_json>`_)
- :class:`TelegramObject.model_dump()` should be used instead of :class:`TelegramObject.to_python()`
(`Read more <https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_dump>`_)