Skip to content

Conversation

@hexatester
Copy link

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

Poolitzer and others added 30 commits May 12, 2020 08:37
# 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
Bibo-Joshi and others added 10 commits August 16, 2020 19:41
* 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
@Bibo-Joshi Bibo-Joshi changed the base branch from type_hinting_master to master August 19, 2020 20:09
@Bibo-Joshi
Copy link
Member

Hi! Thanks for the PR.
I ran the tests on my machine and most of them fail because tg.Base.de_json() doesn't work with your changes. I rebased your PR to master because that way the automated tests should run, when you add new commits. you can change it back by hitting "Edit" on the top right corner.
If you want to get this concept PR to minimally working, please go ahead. However, I feel obliged to warn you not fine tune every last bit just now, as we'd have to discuss the idea in the maintainers group before preceeding ;)

@hexatester
Copy link
Author

I see, but hash still working from Base as intended right?

I might change the Base class and give it condition like isdataclass(cls) then handle it different way from the others.

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?

@Bibo-Joshi
Copy link
Member

uhm, currently the tests don't come further than test_animation. I think you should be able to see the log by clickling on "Details".

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 …

@hexatester
Copy link
Author

uhm, currently the tests don't come further than test_animation. I think you should be able to see the log by clickling on "Details".

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.
Its fine about adding dataclasses to ptb next year, im just testing to see is it possible or not.

@hexatester hexatester closed this Aug 21, 2020
@hexatester hexatester reopened this Aug 21, 2020
@hexatester
Copy link
Author

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.

@hexatester hexatester closed this Aug 21, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants