Deprecation warnings equalisation

This commit is contained in:
Badiboy 2023-03-25 15:17:29 +03:00
parent b0740a920a
commit c9ef0d71f0
3 changed files with 34 additions and 40 deletions

View File

@ -1028,7 +1028,7 @@ class TeleBot:
:return:
"""
if none_stop is not None:
logger.warning("polling: none_stop parameter is deprecated. Use non_stop instead.")
logger.warning('The parameter "none_stop" is deprecated. Use "non_stop" instead.')
non_stop = none_stop
if skip_pending:
@ -1918,7 +1918,7 @@ class TeleBot:
if thumb is not None and thumbnail is None:
thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead')
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json(
apihelper.send_audio(
@ -2086,11 +2086,12 @@ class TeleBot:
if data and not(document):
# function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "document" instead.')
document = data
if thumb is not None and thumbnail is None:
thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead')
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json(
apihelper.send_data(
@ -2166,6 +2167,7 @@ class TeleBot:
if data and not(sticker):
# function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "sticker" instead.')
sticker = data
return types.Message.de_json(
@ -2272,11 +2274,12 @@ class TeleBot:
if data and not(video):
# function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "video" instead.')
video = data
if thumb is not None and thumbnail is None:
thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead')
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json(
apihelper.send_video(
@ -3033,9 +3036,7 @@ class TeleBot:
can_invite_users=can_invite_users,
can_pin_messages=can_pin_messages
)
logger.warning(
"Individual parameters are deprecated and will be removed, use 'permissions' instead."
)
logger.warning('The parameters "can_..." are deprecated, use "permissions" instead.')
return apihelper.restrict_chat_member(
self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions)
@ -3118,7 +3119,7 @@ class TeleBot:
:rtype: :obj:`bool`
"""
if can_manage_voice_chats is not None:
logger.warning("promote_chat_member: can_manage_voice_chats parameter is deprecated. Use can_manage_video_chats instead.")
logger.warning('The parameter "can_manage_voice_chats" is deprecated. Use "can_manage_video_chats" instead.')
if can_manage_video_chats is None:
can_manage_video_chats = can_manage_voice_chats
@ -4745,7 +4746,7 @@ class TeleBot:
:rtype: :class:`telebot.types.File`
"""
if png_sticker:
logger.warning("png_sticker is deprecated, use sticker instead", DeprecationWarning)
logger.warning('The parameter "png_sticker" is deprecated. Use "sticker" instead.')
sticker = png_sticker
sticker_format = "static"
@ -4903,10 +4904,7 @@ class TeleBot:
if sticker is None:
old_sticker = png_sticker or tgs_sticker or webm_sticker
if old_sticker is not None:
logger.warning(
'The parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, '
'use "sticker" instead'
)
logger.warning('The parameters "..._sticker", "emojis" and "mask_position" are deprecated, use "sticker" instead')
if not old_sticker:
raise ValueError('You must pass at least one sticker.')
sticker = types.InputSticker(old_sticker, emojis, mask_position)

View File

@ -294,7 +294,7 @@ class AsyncTeleBot:
:return:
"""
if none_stop is not None:
logger.warning("polling: none_stop parameter is deprecated. Use non_stop instead.")
logger.warning('The parameter "none_stop" is deprecated. Use "non_stop" instead.')
non_stop = none_stop
if skip_pending:
@ -2944,11 +2944,12 @@ class AsyncTeleBot:
if data and not(document):
# function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "document" instead.')
document = data
if thumb is not None and thumbnail is None:
thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead')
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json(
await asyncio_helper.send_data(
@ -3021,7 +3022,7 @@ class AsyncTeleBot:
if data and not(sticker):
# function typo miss compatibility
logger.warning("send_sticker: data parameter is deprecated. Use sticker instead.")
logger.warning('The parameter "data" is deprecated. Use "sticker" instead.')
sticker = data
return types.Message.de_json(
@ -3128,11 +3129,11 @@ class AsyncTeleBot:
if data and not(video):
# function typo miss compatibility
logger.warning("send_sticker: data parameter is deprecated. Use video instead.")
logger.warning('The parameter "data" is deprecated. Use "video" instead.')
video = data
if thumb and not(thumbnail):
logger.warning("send_sticker: thumb parameter is deprecated. Use thumbnail instead.")
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
thumbnail = thumb
return types.Message.de_json(
@ -3234,7 +3235,7 @@ class AsyncTeleBot:
if thumb is not None and thumbnail is None:
thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead')
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json(
await asyncio_helper.send_animation(
@ -3314,7 +3315,7 @@ class AsyncTeleBot:
if thumb is not None and thumbnail is None:
thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead')
logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json(
await asyncio_helper.send_video_note(
@ -3887,9 +3888,7 @@ class AsyncTeleBot:
can_invite_users=can_invite_users,
can_pin_messages=can_pin_messages
)
logger.warning(
"Individual parameters are deprecated and will be removed, use 'permissions' instead."
)
logger.warning('The parameters "can_..." are deprecated, use "permissions" instead.')
return await asyncio_helper.restrict_chat_member(
self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions)
@ -3973,7 +3972,7 @@ class AsyncTeleBot:
"""
if can_manage_voice_chats is not None:
logger.warning("promote_chat_member: can_manage_voice_chats parameter is deprecated. Use can_manage_video_chats instead.")
logger.warning('The parameter "can_manage_voice_chats" is deprecated. Use "can_manage_video_chats" instead.')
if can_manage_video_chats is None:
can_manage_video_chats = can_manage_voice_chats
@ -5539,7 +5538,7 @@ class AsyncTeleBot:
:rtype: :class:`telebot.types.File`
"""
if png_sticker:
logger.warning("png_sticker is deprecated, use sticker instead", DeprecationWarning)
logger.warning('The parameter "png_sticker" is deprecated. Use "sticker" instead.')
sticker = png_sticker
sticker_format = "static"
@ -5761,10 +5760,7 @@ class AsyncTeleBot:
if sticker is None:
old_sticker = png_sticker or tgs_sticker or webm_sticker
if old_sticker is not None:
logger.warning(
'Parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, '
'use "sticker" instead'
)
logger.warning('The parameters "..._sticker", "emojis" and "mask_position" are deprecated, use "sticker" instead')
if not old_sticker:
raise ValueError('You must pass at least one sticker.')
sticker = types.InputSticker(old_sticker, emojis, mask_position)

View File

@ -1582,7 +1582,7 @@ class Audio(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@ -1677,7 +1677,7 @@ class Document(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@ -1741,7 +1741,7 @@ class Video(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@ -1791,7 +1791,7 @@ class VideoNote(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@ -5493,7 +5493,7 @@ class Animation(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@ -5918,7 +5918,7 @@ class StickerSet(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@property
@ -6024,7 +6024,7 @@ class Sticker(JsonDeserializable):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
@ -6225,7 +6225,7 @@ class InputMediaVideo(InputMedia):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
def to_dict(self):
@ -6301,7 +6301,7 @@ class InputMediaAnimation(InputMedia):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
def to_dict(self):
@ -6371,7 +6371,7 @@ class InputMediaAudio(InputMedia):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
def to_dict(self):
@ -6432,7 +6432,7 @@ class InputMediaDocument(InputMedia):
@property
def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead')
logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail
def to_dict(self):