Remove deprecated code (#1012)

* JobQueue: Remove deprecated prevent_autostart & put()

* Bot, Updater: Remove deprecated network_delay

* Remove deprecated Message.new_chat_member

closes #795
This commit is contained in:
Noam Meltzer 2018-02-22 14:17:06 +02:00 committed by GitHub
parent 36a93e0636
commit 3762792cca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 5 additions and 79 deletions

View file

@ -1707,7 +1707,6 @@ class Bot(TelegramObject):
offset=None,
limit=100,
timeout=0,
network_delay=None,
read_latency=2.,
allowed_updates=None,
**kwargs):
@ -1751,10 +1750,6 @@ class Bot(TelegramObject):
"""
url = '{0}/getUpdates'.format(self.base_url)
if network_delay is not None:
warnings.warn('network_delay is deprecated, use read_latency instead')
read_latency = network_delay
data = {'timeout': timeout}
if offset:

View file

@ -277,7 +277,7 @@ class Filters(object):
return bool(message.new_chat_members)
new_chat_members = _NewChatMembers()
""":obj:`Filter`: Messages that contain :attr:`telegram.Message.new_chat_member`."""
""":obj:`Filter`: Messages that contain :attr:`telegram.Message.new_chat_members`."""
class _LeftChatMember(BaseFilter):
name = 'Filters.status_update.left_chat_member'
@ -368,7 +368,7 @@ class Filters(object):
"""Subset for messages containing a status update.
Examples:
Use these filters like: ``Filters.status_update.new_chat_member`` etc. Or use just
Use these filters like: ``Filters.status_update.new_chat_members`` etc. Or use just
``Filters.status_update`` for all status update messages.
Attributes:
@ -384,7 +384,7 @@ class Filters(object):
:attr:`telegram.Message.migrate_from_chat_id` or
:attr: `telegram.Message.migrate_from_chat_id`.
new_chat_members (:obj:`Filter`): Messages that contain
:attr:`telegram.Message.new_chat_member`.
:attr:`telegram.Message.new_chat_members`.
new_chat_photo (:obj:`Filter`): Messages that contain
:attr:`telegram.Message.new_chat_photo`.
new_chat_title (:obj:`Filter`): Messages that contain

View file

@ -20,7 +20,6 @@
import logging
import time
import warnings
import datetime
import weakref
from numbers import Number
@ -43,16 +42,9 @@ class JobQueue(object):
Args:
bot (:class:`telegram.Bot`): The bot instance that should be passed to the jobs.
Deprecated:
prevent_autostart (:obj:`bool`, optional): Thread does not start during initialisation.
Use `start` method instead.
"""
def __init__(self, bot, prevent_autostart=None):
if prevent_autostart is not None:
warnings.warn("prevent_autostart is being deprecated, use `start` method instead.")
def __init__(self, bot):
self._queue = PriorityQueue()
self.bot = bot
self.logger = logging.getLogger(self.__class__.__name__)
@ -63,37 +55,6 @@ class JobQueue(object):
self._next_peek = None
self._running = False
def put(self, job, next_t=None):
"""Queue a new job.
Note:
This method is deprecated. Please use: :attr:`run_once`, :attr:`run_daily`
or :attr:`run_repeating` instead.
Args:
job (:class:`telegram.ext.Job`): The ``Job`` instance representing the new job.
next_t (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | \
:obj:`datetime.datetime` | :obj:`datetime.time`, optional):
Time in or at which the job should run for the first time. This parameter will
be interpreted depending on its type.
* :obj:`int` or :obj:`float` will be interpreted as "seconds from now" in which the
job should run.
* :obj:`datetime.timedelta` will be interpreted as "time from now" in which the
job should run.
* :obj:`datetime.datetime` will be interpreted as a specific date and time at
which the job should run.
* :obj:`datetime.time` will be interpreted as a specific time at which the job
should run. This could be either today or, if the time has already passed,
tomorrow.
"""
warnings.warn("'JobQueue.put' is being deprecated, use 'JobQueue.run_once', "
"'JobQueue.run_daily' or 'JobQueue.run_repeating' instead")
if job.job_queue is None:
job.job_queue = self
self._put(job, next_t=next_t)
def _put(self, job, next_t=None, last_t=None):
if next_t is None:
next_t = job.interval

View file

@ -21,7 +21,6 @@
import logging
import os
import ssl
import warnings
from threading import Thread, Lock, current_thread, Event
from time import sleep
import subprocess
@ -157,7 +156,6 @@ class Updater(object):
def start_polling(self,
poll_interval=0.0,
timeout=10,
network_delay=None,
clean=False,
bootstrap_retries=0,
read_latency=2.,
@ -182,18 +180,11 @@ class Updater(object):
read_latency (:obj:`float` | :obj:`int`, optional): Grace time in seconds for receiving
the reply from server. Will be added to the `timeout` value and used as the read
timeout from server (Default: 2).
network_delay: Deprecated. Will be honoured as :attr:`read_latency` for a while but
will be removed in the future.
Returns:
:obj:`Queue`: The update queue that can be filled from the main thread.
"""
if network_delay is not None:
warnings.warn('network_delay is deprecated, use read_latency instead')
read_latency = network_delay
with self.__lock:
if not self.running:
self.running = True

View file

@ -24,7 +24,6 @@ from telegram import (Audio, Contact, Document, Chat, Location, PhotoSize, Stick
User, Video, Voice, Venue, MessageEntity, Game, Invoice, SuccessfulPayment,
VideoNote)
from telegram import ParseMode
from telegram.utils.deprecate import warn_deprecate_obj
from telegram.utils.helpers import escape_html, escape_markdown, to_timestamp, from_timestamp
_UNDEFINED = object()
@ -99,9 +98,6 @@ class Message(TelegramObject):
in channels.
bot (:class:`telegram.Bot`): Optional. The Bot to use for instance methods.
Deprecated: 6.0
new_chat_member (:class:`telegram.User`): Replaced with :attr:`new_chat_members`
Args:
message_id (:obj:`int`): Unique message identifier inside this chat.
from_user (:class:`telegram.User`, optional): Sender, can be empty for messages sent
@ -234,7 +230,6 @@ class Message(TelegramObject):
contact=None,
location=None,
venue=None,
new_chat_member=None,
left_chat_member=None,
new_chat_title=None,
new_chat_photo=None,
@ -279,7 +274,6 @@ class Message(TelegramObject):
self.contact = contact
self.location = location
self.venue = venue
self._new_chat_member = new_chat_member
self.new_chat_members = new_chat_members or list()
self.left_chat_member = left_chat_member
self.new_chat_title = new_chat_title
@ -336,7 +330,6 @@ class Message(TelegramObject):
data['contact'] = Contact.de_json(data.get('contact'), bot)
data['location'] = Location.de_json(data.get('location'), bot)
data['venue'] = Venue.de_json(data.get('venue'), bot)
data['new_chat_member'] = User.de_json(data.get('new_chat_member'), bot)
data['new_chat_members'] = User.de_list(data.get('new_chat_members'), bot)
data['left_chat_member'] = User.de_json(data.get('left_chat_member'), bot)
data['new_chat_photo'] = PhotoSize.de_list(data.get('new_chat_photo'), bot)
@ -401,7 +394,6 @@ class Message(TelegramObject):
data['caption_entities'] = [e.to_dict() for e in self.caption_entities]
if self.new_chat_photo:
data['new_chat_photo'] = [p.to_dict() for p in self.new_chat_photo]
data['new_chat_member'] = data.pop('_new_chat_member', None)
if self.new_chat_members:
data['new_chat_members'] = [u.to_dict() for u in self.new_chat_members]
@ -1005,9 +997,3 @@ class Message(TelegramObject):
"""
return self._text_markdown(urled=True)
@property
def new_chat_member(self):
"""Deprecated"""
warn_deprecate_obj('new_chat_member', 'new_chat_members')
return self._new_chat_member

View file

@ -216,9 +216,6 @@ class TestJobQueue(object):
def test_warnings(self, job_queue):
j = Job(self.job_run_once, repeat=False)
with pytest.warns(UserWarning):
job_queue.put(j, next_t=0)
j.schedule_removal()
with pytest.raises(ValueError, match='can not be set to'):
j.repeat = True
j.interval = 15

View file

@ -28,11 +28,7 @@ from telegram.vendor.ptb_urllib3 import urllib3
import telegram
IGNORED_OBJECTS = ('ResponseParameters', 'CallbackGame')
IGNORED_PARAMETERS = {'self', 'args', 'kwargs', 'read_latency', 'network_delay', 'timeout', 'bot',
'new_chat_member'}
# TODO: New_chat_member is still in our lib but already removed from TG's docs.
IGNORED_PARAMETERS = {'self', 'args', 'kwargs', 'read_latency', 'network_delay', 'timeout', 'bot'}
def find_next_sibling_until(tag, name, until):