Drop Backward Compatibility Layer Introduced in #3853 (API 6.8) (#3873)

This commit is contained in:
Bibo-Joshi 2023-10-03 15:15:17 +02:00 committed by GitHub
parent 63977ea353
commit 61b70efb4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 34 deletions

View file

@ -29,8 +29,6 @@ from telegram._utils import enum
from telegram._utils.argumentparsing import parse_sequence_arg
from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
from telegram._utils.types import JSONDict
from telegram._utils.warnings import warn
from telegram.warnings import PTBDeprecationWarning
if TYPE_CHECKING:
from telegram import Bot
@ -89,9 +87,11 @@ class PollAnswer(TelegramObject):
.. versionchanged:: 20.5
The order of :paramref:`option_ids` and :paramref:`user` is changed in
20.5 as the latter one became optional. We currently provide
backward compatibility for this but it will be removed in the future.
Please update your code to use the new order.
20.5 as the latter one became optional.
.. versionchanged:: NEXT.VERSION
Backward compatiblity for changed order of :paramref:`option_ids` and :paramref:`user`
was removed.
Args:
poll_id (:obj:`str`): Unique poll identifier.
@ -145,21 +145,8 @@ class PollAnswer(TelegramObject):
super().__init__(api_kwargs=api_kwargs)
self.poll_id: str = poll_id
self.voter_chat: Optional[Chat] = voter_chat
if isinstance(option_ids, User) or isinstance(user, tuple):
warn(
"From v20.5 the order of `option_ids` and `user` is changed as the latter one"
" became optional. Please update your code to use the new order.",
category=PTBDeprecationWarning,
stacklevel=2,
)
self.option_ids: Tuple[int, ...] = parse_sequence_arg(user)
self.user: Optional[User] = option_ids
else:
self.option_ids: Tuple[int, ...] = parse_sequence_arg( # type: ignore[no-redef]
option_ids
)
self.user: Optional[User] = user # type: ignore[no-redef]
self.option_ids: Tuple[int, ...] = parse_sequence_arg(option_ids)
self.user: Optional[User] = user
self._id_attrs = (
self.poll_id,

View file

@ -22,7 +22,6 @@ import pytest
from telegram import Chat, MessageEntity, Poll, PollAnswer, PollOption, User
from telegram._utils.datetime import UTC, to_timestamp
from telegram.constants import PollType
from telegram.warnings import PTBDeprecationWarning
from tests.auxil.slots import mro_slots
@ -144,19 +143,6 @@ class TestPollAnswerWithoutRequest(TestPollAnswerBase):
assert a != f
assert hash(a) != hash(f)
def test_order_warning(self, recwarn):
expected_warning = (
"From v20.5 the order of `option_ids` and `user` is changed as the latter one"
" became optional. Please update your code to use the new order."
)
PollAnswer(123, [2], self.user, self.voter_chat)
assert len(recwarn) == 0
PollAnswer(123, self.user, [2], self.voter_chat)
assert len(recwarn) == 1
assert str(recwarn[0].message) == expected_warning
assert recwarn[0].category is PTBDeprecationWarning
assert recwarn[0].filename == __file__, "wrong stacklevel"
@pytest.fixture(scope="module")
def poll():