-
Notifications
You must be signed in to change notification settings - Fork 6k
dataclass implementation #2056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dataclass implementation #2056
Conversation
# Conflicts: # telegram/message.py
# Conflicts: # telegram/__main__.py # telegram/bot.py # telegram/callbackquery.py # telegram/chatmember.py # telegram/choseninlineresult.py # telegram/error.py # telegram/ext/callbackqueryhandler.py # telegram/ext/commandhandler.py # telegram/ext/conversationhandler.py # telegram/ext/dictpersistence.py # telegram/ext/filters.py # telegram/ext/inlinequeryhandler.py # telegram/ext/jobqueue.py # telegram/ext/messagequeue.py # telegram/ext/picklepersistence.py # telegram/ext/regexhandler.py # telegram/ext/stringcommandhandler.py # telegram/ext/stringregexhandler.py # telegram/ext/typehandler.py # telegram/files/animation.py # telegram/files/document.py # telegram/files/sticker.py # telegram/files/venue.py # telegram/files/video.py # telegram/files/videonote.py # telegram/files/voice.py # telegram/games/game.py # telegram/games/gamehighscore.py # telegram/inline/inlinekeyboardmarkup.py # telegram/inline/inlinequery.py # telegram/message.py # telegram/messageentity.py # telegram/passport/credentials.py # telegram/passport/encryptedpassportelement.py # telegram/passport/passportdata.py # telegram/passport/passportfile.py # telegram/payment/orderinfo.py # telegram/payment/precheckoutquery.py # telegram/payment/shippingoption.py # telegram/payment/shippingquery.py # telegram/payment/successfulpayment.py # telegram/poll.py # telegram/replykeyboardmarkup.py # telegram/update.py # telegram/user.py # telegram/userprofilephotos.py # telegram/utils/helpers.py # telegram/utils/webhookhandler.py
# Conflicts: # .github/workflows/test.yml # telegram/bot.py # telegram/dice.py # telegram/ext/jobqueue.py # telegram/files/animation.py # telegram/files/audio.py # telegram/files/document.py # telegram/files/photosize.py # telegram/files/sticker.py # telegram/files/video.py # telegram/files/videonote.py # telegram/files/voice.py # telegram/inline/inlinequeryresultgif.py # telegram/inline/inlinequeryresultmpeg4gif.py # telegram/message.py # telegram/passport/passportfile.py # telegram/utils/request.py
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* First go on refactoring JobQueue * Temporarily enable tests for the v13 branch * Work on tests * Temporarily enable tests for the v13 branch * Increase coverage * Remove JobQueue.tick() # Was intended for interal use anyways # Fixes tests * Address review * Temporarily enable tests for the v13 branch * Address review * Dispatch errors * Fix handling of job_kwargs * Remove possibility to pass a Bot to JobQueue
* Refactor persistence of bots * User BP.set_bot in Dispatcher * Temporarily enable tests for the v13 branch * Add documentation
* Make most objects comparable * ID attrs for PollAnswer * fix test_game * fix test_userprofilephotos * update for API 4.7 * Warn on meaningless comparisons * Update for API 4.8 * Address review * Get started on docs, update Message._id_attrs * Change PollOption & InputLocation * Some more changes * Even more changes
# Conflicts: # .github/workflows/test.yml # telegram/bot.py # telegram/botcommand.py # telegram/chatpermissions.py # telegram/dice.py # telegram/ext/basepersistence.py # telegram/ext/filters.py # telegram/ext/jobqueue.py # telegram/files/animation.py # telegram/files/audio.py # telegram/files/document.py # telegram/files/photosize.py # telegram/files/sticker.py # telegram/files/video.py # telegram/files/videonote.py # telegram/files/voice.py # telegram/games/game.py # telegram/inline/inlinekeyboardbutton.py # telegram/inline/inlinequeryresultgif.py # telegram/inline/inlinequeryresultmpeg4gif.py # telegram/message.py # telegram/passport/passportfile.py # telegram/payment/invoice.py # telegram/poll.py # telegram/replykeyboardmarkup.py # telegram/utils/request.py # telegram/webhookinfo.py # tests/test_filters.py # tests/test_message.py
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* First go on refactoring JobQueue * Temporarily enable tests for the v13 branch * Work on tests * Temporarily enable tests for the v13 branch * Increase coverage * Remove JobQueue.tick() # Was intended for interal use anyways # Fixes tests * Address review * Temporarily enable tests for the v13 branch * Address review * Dispatch errors * Fix handling of job_kwargs * Remove possibility to pass a Bot to JobQueue
* Refactor persistence of bots * User BP.set_bot in Dispatcher * Temporarily enable tests for the v13 branch * Add documentation
* Make most objects comparable * ID attrs for PollAnswer * fix test_game * fix test_userprofilephotos * update for API 4.7 * Warn on meaningless comparisons * Update for API 4.8 * Address review * Get started on docs, update Message._id_attrs * Change PollOption & InputLocation * Some more changes * Even more changes
* Refactor handling of `default_quote` * Make it a breaking change * Pickle a bots defaults * Temporarily enable tests for the v13 branch * Temporarily enable tests for the v13 branch * Refactor handling of kwargs in Bot methods (#1924) * Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods * Refactor JobQueue (#1981) * First go on refactoring JobQueue * Temporarily enable tests for the v13 branch * Work on tests * Temporarily enable tests for the v13 branch * Increase coverage * Remove JobQueue.tick() # Was intended for interal use anyways # Fixes tests * Address review * Temporarily enable tests for the v13 branch * Address review * Dispatch errors * Fix handling of job_kwargs * Remove possibility to pass a Bot to JobQueue * Refactor persistence of Bot instances (#1994) * Refactor persistence of bots * User BP.set_bot in Dispatcher * Temporarily enable tests for the v13 branch * Add documentation * Add warning to Updater for passing both defaults and bot * Address review * Fix test
* Refactor handling of message vs update filters * address review
# Conflicts: # .github/workflows/test.yml # telegram/bot.py # telegram/botcommand.py # telegram/chat.py # telegram/chatpermissions.py # telegram/dice.py # telegram/ext/basepersistence.py # telegram/ext/dispatcher.py # telegram/ext/filters.py # telegram/ext/jobqueue.py # telegram/ext/updater.py # telegram/files/animation.py # telegram/files/audio.py # telegram/files/document.py # telegram/files/photosize.py # telegram/files/sticker.py # telegram/files/venue.py # telegram/files/video.py # telegram/files/videonote.py # telegram/files/voice.py # telegram/games/game.py # telegram/inline/inlinekeyboardbutton.py # telegram/inline/inlinekeyboardmarkup.py # telegram/message.py # telegram/passport/passportfile.py # telegram/payment/invoice.py # telegram/poll.py # telegram/replykeyboardmarkup.py # telegram/update.py # telegram/user.py # telegram/userprofilephotos.py # telegram/utils/request.py # telegram/utils/webhookhandler.py # telegram/webhookinfo.py # tests/test_message.py # tests/test_updater.py
|
Hi! Thanks for the PR. |
|
I see, but hash still working from Base as intended right? I might change the Base class and give it condition like But still i didn't find any way to add **kwargs inside init of dataclass. I'll get this PR minimally working asap, can you just send me failed test logs? |
|
uhm, currently the tests don't come further than I also became aware that dataclasses are new in Py3.7 and as 3.6 reaches EOL only at the end of 2021 I don't think that we'll be willing to drop 3.6 before autumn 2021 … |
Okay. |
|
I'll close this PR for now. At least we know it's definitely possible to refactor ptb using dataclass. Thanks, also this really help my project. |
This only change class init & sub-classing class constants.
Might wanna install dacite to create an instance of data from dict without making a sweat.
I cant test this locally because the tests always timeout after a few tests on my pc.
https://docs.python.org/3/library/dataclasses.html#post-init-processing
https://stackoverflow.com/questions/52390576/how-can-i-make-a-python-dataclass-hashable