Skip to content
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f5bdffd
Add `typing_extensions`
aelkheir Aug 19, 2026
d6c35bd
Set ruff `typing-extensions=false`
aelkheir Aug 19, 2026
ae4210c
Add `tg{dataclass,field}` helpers
aelkheir Aug 21, 2026
e20a074
Do ground work in `TelegramObject`
aelkheir Aug 19, 2026
b4bbfa3
Add runtime support for specifier parameter `alias`
aelkheir Aug 22, 2026
0026d93
Some typing improvements to `_utils/dataclass.py`
aelkheir Aug 23, 2026
12abacf
Migrate classes direclty under `telegram/`
aelkheir Aug 23, 2026
d19ccdc
Add chango fragment for PR #5334
aelkheir Aug 23, 2026
ea65eea
Finish up classes under `telegram/**/`
aelkheir Sep 10, 2026
8218317
Migrate `Bot` and `ExtBot`
aelkheir Sep 13, 2026
60c1ea0
Remove `test_slot_behaviour()` where its automated
aelkheir Sep 12, 2026
cf8bea0
Add missing default `None` to optional fields
aelkheir Sep 13, 2026
edb225e
Fix some enum copy-paste typos
aelkheir Sep 13, 2026
9e6d558
Override dataclasses generated `__hash__()`
aelkheir Sep 15, 2026
2d88fd0
Handle annotation replacements in generated` __init__`
aelkheir Sep 15, 2026
b17b6b8
Remove `__[get/set]state__` that dataclasses generate
aelkheir Sep 17, 2026
bfc7812
Update two tests that relied on uneeded type coercion
aelkheir Sep 15, 2026
9c53a39
Fix a `test_chatmemberupdated` failure
aelkheir Sep 15, 2026
0a33d49
Update `test_telegramobject` to use `@tg_dataclass()`
aelkheir Sep 15, 2026
37705e0
Remove old "deepcopy preserves freezing" test
aelkheir Sep 17, 2026
92dd955
Deprecate test_telegramobject `test_subclasses_have_api_kwargs`
aelkheir Sep 17, 2026
057fde2
Define `_CredentialsBase.*_hash` aliases as fields
aelkheir Sep 15, 2026
fbd5b8b
Handle all the `[un]freezing` in test suite
aelkheir Sep 17, 2026
cf6485b
Migrate `_inputmedia` classes
aelkheir Sep 20, 2026
908a07b
Simplify `passportelementerrors` migration
aelkheir Sep 20, 2026
bf850c9
Restore TO hashing behaviour and add tests for it
aelkheir Sep 21, 2026
557c9b9
Restore equality for direct TO instances
aelkheir Sep 21, 2026
2aa3421
Fix minor bugs in some field definitions
aelkheir Sep 21, 2026
01bb8c5
Document all breaking changes in changelog
aelkheir Sep 22, 2026
bd568f7
Merge remote-tracking branch 'upstream/master' into dataclasses
aelkheir Sep 22, 2026
2389cae
Fix some `test_poll` failures
aelkheir Sep 22, 2026
ed5bc39
Unify TelegramObject comparison tests after removing warnings
aelkheir Sep 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document all breaking changes in changelog
  • Loading branch information
aelkheir committed Sep 22, 2026
commit 01bb8c55292c751c6cbd5c7be5f7a665a23aaa65
31 changes: 29 additions & 2 deletions changes/unreleased/5334.Yat2ZJVdKq3PJCX7kWFLfD.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
breaking = "Dataclasses"
internal = "Dataclasses"
breaking = """Implement Telegram types as dataclasses

PTB has long `stability policy <https://docs.python-telegram-bot.org/en/stable/stability_policy.html>`__. With this release we migrated Telegram types to dataclasses. That, however, had to come with the following breaking changes:

- User defined classes that subclass from :class:`~telegram.TelegramObject` will no longer work unchanged.
- Direct instances of :class:`~telegram.TelegramObject` are frozen by default.
- Loading a pickled :class:`~telegram.TelegramObject` will return a frozen instance by default.
- Comparing a parent :class:`telegram.TelegramObject` with a child whose comparison attributes equal the parent's, or where both have no comparison attributes, will now evaluate to :obj:`False`.
For example:

.. code:: python

parent = BotCommandScope(type=BotCommandScope.DEFAULT)
child = BotCommandScopeDefault()

parent == child # False in NEXT.VERSION and later
parent == child # True in v22.8

This affects the following parent classes and some or all of their subclasses:
* :class:`~telegram.BackgroundFill`, :class:`~telegram.BackgroundType`, :class:`~telegram.BotCommandScope`, :class:`~telegram.ChatBoostSource`, :class:`~telegram.ChatMember`, :class:`~telegram.InlineQueryResult`, :class:`~telegram.InputMedia`, :class:`~telegram.InputPaidMedia`, :class:`~telegram.InputProfilePhoto`, :class:`~telegram.InputStoryContent`, :class:`~telegram.MaybeInaccessibleMessage`, :class:`~telegram.MenuButton`, :class:`~telegram.MessageOrigin`, :class:`~telegram.ReactionType`, :class:`~telegram.RevenueWithdrawalState`, and :class:`~telegram.TransactionPartner`.

"""
other = """Implement Telegram types as dataclasses

- Comparisons between Telegram objects that have an empty set of attributes that define equality, will no longer emit :class:`telegram.warnings.PTBUserWarning`.
- Removed redundant coercion to :obj:`int` for :attr:`telegram.ChatInviteLink.pending_join_request_count`, :attr:`telegram.Location.proximity_alert_radius`, :attr:`telegram.InlineQueryResultLocation.proximity_alert_radius`, and :attr:`telegram.InputLocationMessageContent.proximity_alert_radius`. Values are now stored as passed.
- Removed redundant coercion to :obj:`str` for ``file_id``, ``file_unique_id`` attributes of Telegram media types, :attr:`telegram.Contact.phone_number`, :attr:`telegram.InlineQueryResult.id`, :attr:`telegram.PassportElementError.source` , and :attr:`telegram.PassportElementError.type`. Values are now stored as passed.

"""
[[pull_requests]]
uid = "5334"
author_uids = ["aelkheir"]
Expand Down