X Tutup
Skip to content

Commit 3762792

Browse files
authored
Remove deprecated code (python-telegram-bot#1012)
* JobQueue: Remove deprecated prevent_autostart & put() * Bot, Updater: Remove deprecated network_delay * Remove deprecated Message.new_chat_member closes python-telegram-bot#795
1 parent 36a93e0 commit 3762792

File tree

7 files changed

+5
-79
lines changed

7 files changed

+5
-79
lines changed

telegram/bot.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,6 @@ def get_updates(self,
17071707
offset=None,
17081708
limit=100,
17091709
timeout=0,
1710-
network_delay=None,
17111710
read_latency=2.,
17121711
allowed_updates=None,
17131712
**kwargs):
@@ -1751,10 +1750,6 @@ def get_updates(self,
17511750
"""
17521751
url = '{0}/getUpdates'.format(self.base_url)
17531752

1754-
if network_delay is not None:
1755-
warnings.warn('network_delay is deprecated, use read_latency instead')
1756-
read_latency = network_delay
1757-
17581753
data = {'timeout': timeout}
17591754

17601755
if offset:

telegram/ext/filters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def filter(self, message):
277277
return bool(message.new_chat_members)
278278

279279
new_chat_members = _NewChatMembers()
280-
""":obj:`Filter`: Messages that contain :attr:`telegram.Message.new_chat_member`."""
280+
""":obj:`Filter`: Messages that contain :attr:`telegram.Message.new_chat_members`."""
281281

282282
class _LeftChatMember(BaseFilter):
283283
name = 'Filters.status_update.left_chat_member'
@@ -368,7 +368,7 @@ def filter(self, message):
368368
"""Subset for messages containing a status update.
369369
370370
Examples:
371-
Use these filters like: ``Filters.status_update.new_chat_member`` etc. Or use just
371+
Use these filters like: ``Filters.status_update.new_chat_members`` etc. Or use just
372372
``Filters.status_update`` for all status update messages.
373373
374374
Attributes:
@@ -384,7 +384,7 @@ def filter(self, message):
384384
:attr:`telegram.Message.migrate_from_chat_id` or
385385
:attr: `telegram.Message.migrate_from_chat_id`.
386386
new_chat_members (:obj:`Filter`): Messages that contain
387-
:attr:`telegram.Message.new_chat_member`.
387+
:attr:`telegram.Message.new_chat_members`.
388388
new_chat_photo (:obj:`Filter`): Messages that contain
389389
:attr:`telegram.Message.new_chat_photo`.
390390
new_chat_title (:obj:`Filter`): Messages that contain

telegram/ext/jobqueue.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import logging
2222
import time
23-
import warnings
2423
import datetime
2524
import weakref
2625
from numbers import Number
@@ -43,16 +42,9 @@ class JobQueue(object):
4342
Args:
4443
bot (:class:`telegram.Bot`): The bot instance that should be passed to the jobs.
4544
46-
Deprecated:
47-
prevent_autostart (:obj:`bool`, optional): Thread does not start during initialisation.
48-
Use `start` method instead.
49-
5045
"""
5146

52-
def __init__(self, bot, prevent_autostart=None):
53-
if prevent_autostart is not None:
54-
warnings.warn("prevent_autostart is being deprecated, use `start` method instead.")
55-
47+
def __init__(self, bot):
5648
self._queue = PriorityQueue()
5749
self.bot = bot
5850
self.logger = logging.getLogger(self.__class__.__name__)
@@ -63,37 +55,6 @@ def __init__(self, bot, prevent_autostart=None):
6355
self._next_peek = None
6456
self._running = False
6557

66-
def put(self, job, next_t=None):
67-
"""Queue a new job.
68-
69-
Note:
70-
This method is deprecated. Please use: :attr:`run_once`, :attr:`run_daily`
71-
or :attr:`run_repeating` instead.
72-
73-
Args:
74-
job (:class:`telegram.ext.Job`): The ``Job`` instance representing the new job.
75-
next_t (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | \
76-
:obj:`datetime.datetime` | :obj:`datetime.time`, optional):
77-
Time in or at which the job should run for the first time. This parameter will
78-
be interpreted depending on its type.
79-
80-
* :obj:`int` or :obj:`float` will be interpreted as "seconds from now" in which the
81-
job should run.
82-
* :obj:`datetime.timedelta` will be interpreted as "time from now" in which the
83-
job should run.
84-
* :obj:`datetime.datetime` will be interpreted as a specific date and time at
85-
which the job should run.
86-
* :obj:`datetime.time` will be interpreted as a specific time at which the job
87-
should run. This could be either today or, if the time has already passed,
88-
tomorrow.
89-
90-
"""
91-
warnings.warn("'JobQueue.put' is being deprecated, use 'JobQueue.run_once', "
92-
"'JobQueue.run_daily' or 'JobQueue.run_repeating' instead")
93-
if job.job_queue is None:
94-
job.job_queue = self
95-
self._put(job, next_t=next_t)
96-
9758
def _put(self, job, next_t=None, last_t=None):
9859
if next_t is None:
9960
next_t = job.interval

telegram/ext/updater.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import logging
2222
import os
2323
import ssl
24-
import warnings
2524
from threading import Thread, Lock, current_thread, Event
2625
from time import sleep
2726
import subprocess
@@ -157,7 +156,6 @@ def _thread_wrapper(self, target, *args, **kwargs):
157156
def start_polling(self,
158157
poll_interval=0.0,
159158
timeout=10,
160-
network_delay=None,
161159
clean=False,
162160
bootstrap_retries=0,
163161
read_latency=2.,
@@ -182,18 +180,11 @@ def start_polling(self,
182180
read_latency (:obj:`float` | :obj:`int`, optional): Grace time in seconds for receiving
183181
the reply from server. Will be added to the `timeout` value and used as the read
184182
timeout from server (Default: 2).
185-
network_delay: Deprecated. Will be honoured as :attr:`read_latency` for a while but
186-
will be removed in the future.
187183
188184
Returns:
189185
:obj:`Queue`: The update queue that can be filled from the main thread.
190186
191187
"""
192-
193-
if network_delay is not None:
194-
warnings.warn('network_delay is deprecated, use read_latency instead')
195-
read_latency = network_delay
196-
197188
with self.__lock:
198189
if not self.running:
199190
self.running = True

telegram/message.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
User, Video, Voice, Venue, MessageEntity, Game, Invoice, SuccessfulPayment,
2525
VideoNote)
2626
from telegram import ParseMode
27-
from telegram.utils.deprecate import warn_deprecate_obj
2827
from telegram.utils.helpers import escape_html, escape_markdown, to_timestamp, from_timestamp
2928

3029
_UNDEFINED = object()
@@ -99,9 +98,6 @@ class Message(TelegramObject):
9998
in channels.
10099
bot (:class:`telegram.Bot`): Optional. The Bot to use for instance methods.
101100
102-
Deprecated: 6.0
103-
new_chat_member (:class:`telegram.User`): Replaced with :attr:`new_chat_members`
104-
105101
Args:
106102
message_id (:obj:`int`): Unique message identifier inside this chat.
107103
from_user (:class:`telegram.User`, optional): Sender, can be empty for messages sent
@@ -234,7 +230,6 @@ def __init__(self,
234230
contact=None,
235231
location=None,
236232
venue=None,
237-
new_chat_member=None,
238233
left_chat_member=None,
239234
new_chat_title=None,
240235
new_chat_photo=None,
@@ -279,7 +274,6 @@ def __init__(self,
279274
self.contact = contact
280275
self.location = location
281276
self.venue = venue
282-
self._new_chat_member = new_chat_member
283277
self.new_chat_members = new_chat_members or list()
284278
self.left_chat_member = left_chat_member
285279
self.new_chat_title = new_chat_title
@@ -336,7 +330,6 @@ def de_json(cls, data, bot):
336330
data['contact'] = Contact.de_json(data.get('contact'), bot)
337331
data['location'] = Location.de_json(data.get('location'), bot)
338332
data['venue'] = Venue.de_json(data.get('venue'), bot)
339-
data['new_chat_member'] = User.de_json(data.get('new_chat_member'), bot)
340333
data['new_chat_members'] = User.de_list(data.get('new_chat_members'), bot)
341334
data['left_chat_member'] = User.de_json(data.get('left_chat_member'), bot)
342335
data['new_chat_photo'] = PhotoSize.de_list(data.get('new_chat_photo'), bot)
@@ -401,7 +394,6 @@ def to_dict(self):
401394
data['caption_entities'] = [e.to_dict() for e in self.caption_entities]
402395
if self.new_chat_photo:
403396
data['new_chat_photo'] = [p.to_dict() for p in self.new_chat_photo]
404-
data['new_chat_member'] = data.pop('_new_chat_member', None)
405397
if self.new_chat_members:
406398
data['new_chat_members'] = [u.to_dict() for u in self.new_chat_members]
407399

@@ -1005,9 +997,3 @@ def text_markdown_urled(self):
1005997
1006998
"""
1007999
return self._text_markdown(urled=True)
1008-
1009-
@property
1010-
def new_chat_member(self):
1011-
"""Deprecated"""
1012-
warn_deprecate_obj('new_chat_member', 'new_chat_members')
1013-
return self._new_chat_member

tests/test_jobqueue.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ def test_run_daily(self, job_queue):
216216

217217
def test_warnings(self, job_queue):
218218
j = Job(self.job_run_once, repeat=False)
219-
with pytest.warns(UserWarning):
220-
job_queue.put(j, next_t=0)
221-
j.schedule_removal()
222219
with pytest.raises(ValueError, match='can not be set to'):
223220
j.repeat = True
224221
j.interval = 15

tests/test_official.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828
import telegram
2929

3030
IGNORED_OBJECTS = ('ResponseParameters', 'CallbackGame')
31-
IGNORED_PARAMETERS = {'self', 'args', 'kwargs', 'read_latency', 'network_delay', 'timeout', 'bot',
32-
'new_chat_member'}
33-
34-
35-
# TODO: New_chat_member is still in our lib but already removed from TG's docs.
31+
IGNORED_PARAMETERS = {'self', 'args', 'kwargs', 'read_latency', 'network_delay', 'timeout', 'bot'}
3632

3733

3834
def find_next_sibling_until(tag, name, until):

0 commit comments

Comments
 (0)
X Tutup