Setting custom attributes on objects of the PTB library is deprecated? #2555
-
I have been using a custom attribute on the Now I am seeing the TelegramDeprecationWarning that seems related to a recent PR #2345 There is no note about if or when this will go from a warning to a breaking change, and perhaps more importantly, what the reasoning is behind it. I did read the comments on that PR, but it is not obvious to me why it should be a problem for users to enhance the bot in this way, nor how urgent it is for me to take action steps here, nor what those would be. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Quoting the v13.6 release post in the Telegram channel:
|
Beta Was this translation helpful? Give feedback.
-
Hi. Thanks for reaching out. We added Dynamically adding attributes to classes is certainly a useful feature for some use cases in Python, one example being I admit that I used something like Regarding
As @zeroone2numeral2 already pointed out, we made a at least slightly more elaborate announcement on the news channel on Telegram. This is where we always post an overview for new releases, while the changelog in the docs and the GH releases only contain the pure changelog. I'll make sure to link to the release channel in the tchnical changelog for future releases. We'll only remove |
Beta Was this translation helpful? Give feedback.
-
I would be interested in what are you setting in bot and if you can or can not achieve the same with bot_data. |
Beta Was this translation helpful? Give feedback.
Hi. Thanks for reaching out.
We added
__slots__
mostly for the benefits they can bring in terms of menory usage and performance. Disallowing users from adding custom attributes to PTB-classes in the future is more a side effect of this, but one that I support.Dynamically adding attributes to classes is certainly a useful feature for some use cases in Python, one example being
Handler.collect_additional_context
in PTB, which encourages you to add custom attributes to aCallbackContext
object (and this will ofc work in future versions).However, there are also many cases were I'd argue that there is a cleaner solution. E.g. for the types defined by the Bot API, I'd argue that it's unnatura…