Skip to content

Commit eae139d

Browse files
authored
remove de_json() (python-telegram-bot#789)
* remove de_json() * Remove or rename obsolete tests * fixes according to rc
1 parent 160ffed commit eae139d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+52
-631
lines changed

telegram/bot.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,12 +2772,6 @@ def delete_sticker_from_set(self, sticker, timeout=None, **kwargs):
27722772

27732773
return result
27742774

2775-
@classmethod
2776-
def de_json(cls, data, bot):
2777-
data = super(Bot, cls).de_json(data, bot)
2778-
2779-
return cls(**data)
2780-
27812775
def to_dict(self):
27822776
data = {'id': self.id, 'username': self.username, 'first_name': self.username}
27832777

telegram/forcereply.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,3 @@ def __init__(self, force_reply=True, selective=False, **kwargs):
4949
self.force_reply = bool(force_reply)
5050
# Optionals
5151
self.selective = bool(selective)
52-
53-
@classmethod
54-
def de_json(cls, data, bot):
55-
if not data:
56-
return None
57-
58-
return cls(**data)

telegram/inline/inlinekeyboardbutton.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,3 @@ def __init__(self,
8787
self.switch_inline_query_current_chat = switch_inline_query_current_chat
8888
self.callback_game = callback_game
8989
self.pay = pay
90-
91-
@classmethod
92-
def de_json(cls, data, bot):
93-
data = super(InlineKeyboardButton, cls).de_json(data, bot)
94-
95-
if not data:
96-
return None
97-
98-
return cls(**data)
99-
100-
@classmethod
101-
def de_list(cls, data, bot):
102-
if not data:
103-
return []
104-
105-
inline_keyboards = list()
106-
for inline_keyboard in data:
107-
inline_keyboards.append(cls.de_json(inline_keyboard, bot))
108-
109-
return inline_keyboards

telegram/inline/inlinekeyboardmarkup.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains an object that represents a Telegram InlineKeyboardMarkup."""
2020

21-
from telegram import ReplyMarkup, InlineKeyboardButton
21+
from telegram import ReplyMarkup
2222

2323

2424
class InlineKeyboardMarkup(ReplyMarkup):
@@ -40,20 +40,6 @@ def __init__(self, inline_keyboard, **kwargs):
4040
# Required
4141
self.inline_keyboard = inline_keyboard
4242

43-
@classmethod
44-
def de_json(cls, data, bot):
45-
data = super(InlineKeyboardMarkup, cls).de_json(data, bot)
46-
47-
if not data:
48-
return None
49-
50-
data['inline_keyboard'] = [
51-
InlineKeyboardButton.de_list(inline_keyboard, bot)
52-
for inline_keyboard in data['inline_keyboard']
53-
]
54-
55-
return cls(**data)
56-
5743
def to_dict(self):
5844
data = super(InlineKeyboardMarkup, self).to_dict()
5945

telegram/inline/inlinequeryresultarticle.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains the classes that represent Telegram InlineQueryResultArticle."""
2020

21-
from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent
21+
from telegram import InlineQueryResult
2222

2323

2424
class InlineQueryResultArticle(InlineQueryResult):
@@ -91,16 +91,3 @@ def __init__(self,
9191
self.thumb_width = thumb_width
9292
if thumb_height:
9393
self.thumb_height = thumb_height
94-
95-
@classmethod
96-
def de_json(cls, data, bot):
97-
data = super(InlineQueryResultArticle, cls).de_json(data, bot)
98-
99-
if not data:
100-
return None
101-
102-
data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot)
103-
data['input_message_content'] = InputMessageContent.de_json(
104-
data.get('input_message_content'), bot)
105-
106-
return cls(**data)

telegram/inline/inlinequeryresultaudio.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains the classes that represent Telegram InlineQueryResultAudio."""
2020

21-
from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent
21+
from telegram import InlineQueryResult
2222

2323

2424
class InlineQueryResultAudio(InlineQueryResult):
@@ -82,16 +82,3 @@ def __init__(self,
8282
self.reply_markup = reply_markup
8383
if input_message_content:
8484
self.input_message_content = input_message_content
85-
86-
@classmethod
87-
def de_json(cls, data, bot):
88-
data = super(InlineQueryResultAudio, cls).de_json(data, bot)
89-
90-
if not data:
91-
return None
92-
93-
data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot)
94-
data['input_message_content'] = InputMessageContent.de_json(
95-
data.get('input_message_content'), bot)
96-
97-
return cls(**data)

telegram/inline/inlinequeryresultcachedaudio.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains the classes that represent Telegram InlineQueryResultCachedAudio."""
2020

21-
from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent
21+
from telegram import InlineQueryResult
2222

2323

2424
class InlineQueryResultCachedAudio(InlineQueryResult):
@@ -67,16 +67,3 @@ def __init__(self,
6767
self.reply_markup = reply_markup
6868
if input_message_content:
6969
self.input_message_content = input_message_content
70-
71-
@classmethod
72-
def de_json(cls, data, bot):
73-
data = super(InlineQueryResultCachedAudio, cls).de_json(data, bot)
74-
75-
if not data:
76-
return None
77-
78-
data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot)
79-
data['input_message_content'] = InputMessageContent.de_json(
80-
data.get('input_message_content'), bot)
81-
82-
return cls(**data)

telegram/inline/inlinequeryresultcacheddocument.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains the classes that represent Telegram InlineQueryResultCachedDocument."""
2020

21-
from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent
21+
from telegram import InlineQueryResult
2222

2323

2424
class InlineQueryResultCachedDocument(InlineQueryResult):
@@ -76,16 +76,3 @@ def __init__(self,
7676
self.reply_markup = reply_markup
7777
if input_message_content:
7878
self.input_message_content = input_message_content
79-
80-
@classmethod
81-
def de_json(cls, data, bot):
82-
data = super(InlineQueryResultCachedDocument, cls).de_json(data, bot)
83-
84-
if not data:
85-
return None
86-
87-
data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot)
88-
data['input_message_content'] = InputMessageContent.de_json(
89-
data.get('input_message_content'), bot)
90-
91-
return cls(**data)

telegram/inline/inlinequeryresultcachedgif.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains the classes that represent Telegram InlineQueryResultCachedGif."""
2020

21-
from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent
21+
from telegram import InlineQueryResult
2222

2323

2424
class InlineQueryResultCachedGif(InlineQueryResult):
@@ -73,16 +73,3 @@ def __init__(self,
7373
self.reply_markup = reply_markup
7474
if input_message_content:
7575
self.input_message_content = input_message_content
76-
77-
@classmethod
78-
def de_json(cls, data, bot):
79-
data = super(InlineQueryResultCachedGif, cls).de_json(data, bot)
80-
81-
if not data:
82-
return None
83-
84-
data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot)
85-
data['input_message_content'] = InputMessageContent.de_json(
86-
data.get('input_message_content'), bot)
87-
88-
return cls(**data)

telegram/inline/inlinequeryresultcachedmpeg4gif.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif."""
2020

21-
from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent
21+
from telegram import InlineQueryResult
2222

2323

2424
class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
@@ -73,16 +73,3 @@ def __init__(self,
7373
self.reply_markup = reply_markup
7474
if input_message_content:
7575
self.input_message_content = input_message_content
76-
77-
@classmethod
78-
def de_json(cls, data, bot):
79-
data = super(InlineQueryResultCachedMpeg4Gif, cls).de_json(data, bot)
80-
81-
if not data:
82-
return None
83-
84-
data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot)
85-
data['input_message_content'] = InputMessageContent.de_json(
86-
data.get('input_message_content'), bot)
87-
88-
return cls(**data)

0 commit comments

Comments
 (0)