diff --git a/aiogram/types/animation.py b/aiogram/types/animation.py index 07611517..4a6c0939 100644 --- a/aiogram/types/animation.py +++ b/aiogram/types/animation.py @@ -18,8 +18,6 @@ class Animation(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') thumb = PhotoSize.deserialize(raw_data.get('thumb')) file_name = raw_data.get('file_name') diff --git a/aiogram/types/audio.py b/aiogram/types/audio.py index c3566684..b677de56 100644 --- a/aiogram/types/audio.py +++ b/aiogram/types/audio.py @@ -17,8 +17,6 @@ class Audio(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') duration = raw_data.get('duration') performer = raw_data.get('performer') diff --git a/aiogram/types/base.py b/aiogram/types/base.py index 6664a03d..75298940 100644 --- a/aiogram/types/base.py +++ b/aiogram/types/base.py @@ -102,22 +102,6 @@ class Deserializable: """ raise NotImplementedError - @staticmethod - def check_json(raw_data) -> dict: - """ - Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is. - If it is not, it is converted to a dict by means of json.loads(json_type) - :param raw_data: - :return: - """ - - if isinstance(raw_data, dict): - return raw_data - elif isinstance(raw_data, str): - return json.loads(raw_data) - else: - raise ValueError("data should be a json dict or string.") - def __str__(self): return str(self.to_json()) diff --git a/aiogram/types/callback_query.py b/aiogram/types/callback_query.py index ffbabef8..466e4d95 100644 --- a/aiogram/types/callback_query.py +++ b/aiogram/types/callback_query.py @@ -28,8 +28,6 @@ class CallbackQuery(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - id = raw_data.get('id') from_user = User.deserialize(raw_data.get('from')) message = Message.deserialize(raw_data.get('message')) diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index 459a7b70..af710c17 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -25,8 +25,6 @@ class Chat(Deserializable): @classmethod def de_json(cls, raw_data) -> 'Chat': - raw_data = cls.check_json(raw_data) - id: int = raw_data.get('id') type: str = raw_data.get('type') title: str = raw_data.get('title') diff --git a/aiogram/types/chat_member.py b/aiogram/types/chat_member.py index a8a0d37c..01bbcccb 100644 --- a/aiogram/types/chat_member.py +++ b/aiogram/types/chat_member.py @@ -41,8 +41,6 @@ class ChatMember(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - user = User.deserialize(raw_data.get('user')) status = raw_data.get('status') diff --git a/aiogram/types/chat_photo.py b/aiogram/types/chat_photo.py index 4ea30a15..a49e5d1d 100644 --- a/aiogram/types/chat_photo.py +++ b/aiogram/types/chat_photo.py @@ -14,8 +14,6 @@ class ChatPhoto(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - small_file_id = raw_data.get('small_file_id') big_file_id = raw_data.get('big_file_id') diff --git a/aiogram/types/chosen_inline_result.py b/aiogram/types/chosen_inline_result.py index 5f308d09..6d20f916 100644 --- a/aiogram/types/chosen_inline_result.py +++ b/aiogram/types/chosen_inline_result.py @@ -18,8 +18,6 @@ class ChosenInlineResult(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - result_id = raw_data.get('result_id') from_user = User.deserialize(raw_data.get('from')) location = Location.deserialize(raw_data.get('location')) diff --git a/aiogram/types/contact.py b/aiogram/types/contact.py index 582909fa..5d7eca7b 100644 --- a/aiogram/types/contact.py +++ b/aiogram/types/contact.py @@ -15,8 +15,6 @@ class Contact(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - phone_number = raw_data.get('phone_number') first_name = raw_data.get('first_name') last_name = raw_data.get('last_name') diff --git a/aiogram/types/document.py b/aiogram/types/document.py index fdcc5049..8b390df1 100644 --- a/aiogram/types/document.py +++ b/aiogram/types/document.py @@ -17,8 +17,6 @@ class Document(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') thumb = PhotoSize.deserialize(raw_data.get('thumb')) file_name = raw_data.get('file_name') diff --git a/aiogram/types/file.py b/aiogram/types/file.py index 0f07f7ad..44b918ce 100644 --- a/aiogram/types/file.py +++ b/aiogram/types/file.py @@ -19,8 +19,6 @@ class File(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') file_size = raw_data.get('file_size') file_path = raw_data.get('file_path') diff --git a/aiogram/types/game.py b/aiogram/types/game.py index 5ac094f7..beda58e3 100644 --- a/aiogram/types/game.py +++ b/aiogram/types/game.py @@ -22,8 +22,6 @@ class Game(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - title = raw_data.get('title') description = raw_data.get('description') photo = PhotoSize.deserialize(raw_data.get('photo')) diff --git a/aiogram/types/game_high_score.py b/aiogram/types/game_high_score.py index c17ad4b3..9f515640 100644 --- a/aiogram/types/game_high_score.py +++ b/aiogram/types/game_high_score.py @@ -15,8 +15,6 @@ class GameHighScore(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - position = raw_data.get('position') user = User.deserialize(raw_data.get('user')) score = raw_data.get('score') diff --git a/aiogram/types/inline_query.py b/aiogram/types/inline_query.py index eb20b951..b304f4e0 100644 --- a/aiogram/types/inline_query.py +++ b/aiogram/types/inline_query.py @@ -20,8 +20,6 @@ class InlineQuery(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - id = raw_data.get('id') from_user = User.deserialize(raw_data.get('from')) location = Location.deserialize(raw_data.get('location')) diff --git a/aiogram/types/invoice.py b/aiogram/types/invoice.py index 1b1b7364..ab668cf4 100644 --- a/aiogram/types/invoice.py +++ b/aiogram/types/invoice.py @@ -16,8 +16,6 @@ class Invoice(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - title = raw_data.get('title') description = raw_data.get('description') start_parameter = raw_data.get('start_parameter') diff --git a/aiogram/types/location.py b/aiogram/types/location.py index 61b2f82c..316c24c3 100644 --- a/aiogram/types/location.py +++ b/aiogram/types/location.py @@ -13,8 +13,6 @@ class Location(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - longitude = raw_data.get('longitude') latitude = raw_data.get('latitude') diff --git a/aiogram/types/mask_position.py b/aiogram/types/mask_position.py index 3f0b7336..8e3d181b 100644 --- a/aiogram/types/mask_position.py +++ b/aiogram/types/mask_position.py @@ -16,8 +16,6 @@ class MaskPosition(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - point = raw_data.get('point') x_shift = raw_data.get('x_shift') y_shift = raw_data.get('y_shift') diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 9a255871..c4361a42 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -80,8 +80,6 @@ class Message(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - message_id = raw_data.get('message_id') from_user = User.deserialize(raw_data.get('from')) date = cls._parse_date(raw_data.get('date', 0)) diff --git a/aiogram/types/message_entity.py b/aiogram/types/message_entity.py index 83e3b98e..ac5a51b1 100644 --- a/aiogram/types/message_entity.py +++ b/aiogram/types/message_entity.py @@ -20,8 +20,6 @@ class MessageEntity(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - type = raw_data.get('type') offset = raw_data.get('offset') length = raw_data.get('length') diff --git a/aiogram/types/order_info.py b/aiogram/types/order_info.py index 863f52ce..7c469455 100644 --- a/aiogram/types/order_info.py +++ b/aiogram/types/order_info.py @@ -16,8 +16,6 @@ class OrderInfo(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - name = raw_data.get('name') phone_number = raw_data.get('phone_number') email = raw_data.get('email') diff --git a/aiogram/types/photo_size.py b/aiogram/types/photo_size.py index 9b514706..031d964f 100644 --- a/aiogram/types/photo_size.py +++ b/aiogram/types/photo_size.py @@ -15,8 +15,6 @@ class PhotoSize(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') width = raw_data.get('width') height = raw_data.get('height') diff --git a/aiogram/types/pre_checkout_query.py b/aiogram/types/pre_checkout_query.py index 2a534aea..37557681 100644 --- a/aiogram/types/pre_checkout_query.py +++ b/aiogram/types/pre_checkout_query.py @@ -20,8 +20,6 @@ class PreCheckoutQuery(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - id = raw_data.get('id') from_user = User.deserialize(raw_data.get('from')) currency = raw_data.get('currency') diff --git a/aiogram/types/response_parameters.py b/aiogram/types/response_parameters.py index 41ff2808..e2aa1fb4 100644 --- a/aiogram/types/response_parameters.py +++ b/aiogram/types/response_parameters.py @@ -13,8 +13,6 @@ class ResponseParameters(Deserializable): @classmethod def de_json(cls, raw_data): - data = cls.check_json(raw_data) - migrate_to_chat_id = data.get('migrate_to_chat_id') retry_after = data.get('retry_after') diff --git a/aiogram/types/shipping_address.py b/aiogram/types/shipping_address.py index 588a3063..3d3f2429 100644 --- a/aiogram/types/shipping_address.py +++ b/aiogram/types/shipping_address.py @@ -17,8 +17,6 @@ class ShippingAddress(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - country_code = raw_data.get('country_code') state = raw_data.get('state') city = raw_data.get('city') diff --git a/aiogram/types/shipping_query.py b/aiogram/types/shipping_query.py index 4ba2e787..a51137ed 100644 --- a/aiogram/types/shipping_query.py +++ b/aiogram/types/shipping_query.py @@ -17,8 +17,6 @@ class ShippingQuery(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - id = raw_data.get('id') from_user = User.deserialize(raw_data.get('from')) invoice_payload = raw_data.get('invoice_payload') diff --git a/aiogram/types/sticker.py b/aiogram/types/sticker.py index e8af70f0..db3646ad 100644 --- a/aiogram/types/sticker.py +++ b/aiogram/types/sticker.py @@ -22,8 +22,6 @@ class Sticker(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') width = raw_data.get('width') height = raw_data.get('height') diff --git a/aiogram/types/sticker_set.py b/aiogram/types/sticker_set.py index c0e89b84..83752af8 100644 --- a/aiogram/types/sticker_set.py +++ b/aiogram/types/sticker_set.py @@ -17,8 +17,6 @@ class StickerSet(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - name = raw_data.get('name') title = raw_data.get('title') is_mask = raw_data.get('is_mask') diff --git a/aiogram/types/successful_payment.py b/aiogram/types/successful_payment.py index a8c15547..19fc74bd 100644 --- a/aiogram/types/successful_payment.py +++ b/aiogram/types/successful_payment.py @@ -20,8 +20,6 @@ class SuccessfulPayment(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - currency = raw_data.get('currency') total_amount = raw_data.get('total_amount') invoice_payload = raw_data.get('invoice_payload') diff --git a/aiogram/types/update.py b/aiogram/types/update.py index efa49ee8..4a85106f 100644 --- a/aiogram/types/update.py +++ b/aiogram/types/update.py @@ -32,8 +32,6 @@ class Update(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - update_id = raw_data.get('update_id') message = Message.deserialize(raw_data.get('message')) edited_message = Message.deserialize(raw_data.get('edited_message')) diff --git a/aiogram/types/user.py b/aiogram/types/user.py index ed42fa8d..966a563d 100644 --- a/aiogram/types/user.py +++ b/aiogram/types/user.py @@ -21,8 +21,6 @@ class User(Deserializable): @classmethod def de_json(cls, raw_data: str or dict) -> 'User': - raw_data = cls.check_json(raw_data) - id = raw_data.get('id') first_name = raw_data.get('first_name') last_name = raw_data.get('last_name') diff --git a/aiogram/types/user_profile_photos.py b/aiogram/types/user_profile_photos.py index e32a0721..6f06201f 100644 --- a/aiogram/types/user_profile_photos.py +++ b/aiogram/types/user_profile_photos.py @@ -14,8 +14,6 @@ class UserProfilePhotos(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - total_count = raw_data.get('total_count') photos = [PhotoSize.deserialize(item) for item in raw_data.get('photos')] diff --git a/aiogram/types/venue.py b/aiogram/types/venue.py index 254f1050..25b76faf 100644 --- a/aiogram/types/venue.py +++ b/aiogram/types/venue.py @@ -16,8 +16,6 @@ class Venue(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - location = Location.deserialize(raw_data.get('location')) title = raw_data.get('title') address = raw_data.get('address') diff --git a/aiogram/types/video.py b/aiogram/types/video.py index 3bbc3053..e18f929a 100644 --- a/aiogram/types/video.py +++ b/aiogram/types/video.py @@ -19,8 +19,6 @@ class Video(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') width = raw_data.get('width') height = raw_data.get('height') diff --git a/aiogram/types/video_note.py b/aiogram/types/video_note.py index b6542838..7e6ca1f9 100644 --- a/aiogram/types/video_note.py +++ b/aiogram/types/video_note.py @@ -17,8 +17,6 @@ class VideoNote(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') length = raw_data.get('length') duration = raw_data.get('duration') diff --git a/aiogram/types/voice.py b/aiogram/types/voice.py index 3086e625..692abd8c 100644 --- a/aiogram/types/voice.py +++ b/aiogram/types/voice.py @@ -15,8 +15,6 @@ class Voice(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - file_id = raw_data.get('file_id') duration = raw_data.get('duration') mime_type = raw_data.get('mime_type') diff --git a/aiogram/types/webhook_info.py b/aiogram/types/webhook_info.py index b98a85c1..c8b2805b 100644 --- a/aiogram/types/webhook_info.py +++ b/aiogram/types/webhook_info.py @@ -25,8 +25,6 @@ class WebhookInfo(Deserializable): @classmethod def de_json(cls, raw_data): - raw_data = cls.check_json(raw_data) - url = raw_data.get('url') has_custom_certificate = raw_data.get('has_custom_certificate') pending_update_count = raw_data.get('pending_update_count')