8000 Drop Backward Compatibility Layer Introduced in #3853 (API 6.8) (#3873) · guillemap/python-telegram-bot@61b70ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 61b70ef

Browse files
authored
Drop Backward Compatibility Layer Introduced in python-telegram-bot#3853 (API 6.8) (python-telegram-bot#3873)
1 parent 63977ea commit 61b70ef

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

telegram/_poll.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
from telegram._utils.argumentparsing import parse_sequence_arg
3030
from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
3131
from telegram._utils.types import JSONDict
32-
from telegram._utils.warnings import warn
33-
from telegram.warnings import PTBDeprecationWarning
3432

3533
if TYPE_CHECKING:
3634
from telegram import Bot
@@ -89,9 +87,11 @@ class PollAnswer(TelegramObject):
8987
9088
.. versionchanged:: 20.5
9189
The order of :paramref:`option_ids` and :paramref:`user` is changed in
92-
20.5 as the latter one became optional. We currently provide
93-
backward compatibility for this but it will be removed in the future.
94-
Please update your code to use the new order.
90+
20.5 as the latter one became optional.
91+
92+
.. versionchanged:: NEXT.VERSION
93+
Backward compatiblity for changed order of :paramref:`option_ids` and :paramref:`user`
94+
was removed.
9595
9696
Args:
9797
poll_id (:obj:`str`): Unique poll identifier.
@@ -145,21 +145,8 @@ def __init__(
145145
super().__init__(api_kwargs=api_kwargs)
146146
self.poll_id: str = poll_id
147147
self.voter_chat: Optional[Chat] = voter_chat
148-
149-
if isinstance(option_ids, User) or isinstance(user, tuple):
150-
warn(
151-
"From v20.5 the order of `option_ids` and `user` is changed as the latter one"
152-
" became optional. Please update your code to use the new order.",
153-
category=PTBDeprecationWarning,
154-
stacklevel=2,
155-
)
156-
self.option_ids: Tuple[int, ...] = parse_sequence_arg(user)
157-
self.user: Optional[User] = option_ids
158-
else:
159-
self.option_ids: Tuple[int, ...] = parse_sequence_arg( # type: ignore[no-redef]
160-
option_ids
161-
)
162-
self.user: Optional[User] = user # type: ignore[no-redef]
148+
self.option_ids: Tuple[int, ...] = parse_sequence_arg(option_ids)
149+
self.user: Optional[User] = user
163150

164151
self._id_attrs = (
165152
self.poll_id,

tests/test_poll.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from telegram import Chat, MessageEntity, Poll, PollAnswer, PollOption, User
2323
from telegram._utils.datetime import UTC, to_timestamp
2424
from telegram.constants import PollType
25-
from telegram.warnings import PTBDeprecationWarning
2625
from tests.auxil.slots import mro_slots
2726

2827

@@ -144,19 +143,6 @@ def test_equality(self):
144143
assert a != f
145144
assert hash(a) != hash(f)
146145

147-
def test_order_warning(self, recwarn):
148-
expected_warning = (
149-
"From v20.5 the order of `option_ids` and `user` is changed as the latter one"
150-
" became optional. Please update your code to use the new order."
151-
)
152-
PollAnswer(123, [2], self.user, self.voter_chat)
153-
assert len(recwarn) == 0
154-
PollAnswer(123, self.user, [2], self.voter_chat)
155-
assert len(recwarn) == 1
156-
assert str(recwarn[0].message) == expected_warning
157-
assert recwarn[0].category is PTBDeprecationWarning
158-
assert recwarn[0].filename == __file__, "wrong stacklevel"
159-
160146

161147
@pytest.fixture(scope="module")
162148
def poll():

0 commit comments

Comments
 (0)
0