- Notifications
You must be signed in to change notification settings - Fork5.7k
Refactor kwargs handling in Bot methods#1924
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM.
I dont like that we support this, but if the majority thinks this is good, I am okay with it
n5y commentedMay 2, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It's perfectly possible to pass parameters with GET methods, it's one of 4 supported ways to pass parametershttps://core.telegram.org/bots/api#making-requests . Alternatively, there's no need for those methods to use GET instead of POST. Having a separate
|
n5y commentedMay 2, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The |
n5y commentedMay 2, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It seems like there's already bot api specific code in The recent bug with |
Bibo-Joshi commentedMay 2, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
As I understood from the discussion with Noam about that recent bug, Unifying the construction of the URL, seems a good idea to me, too. Putting it in |
n5y commentedMay 2, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Where does network stuff end and bot stuff begin? In context of dealing with Bot API, setting base url is about as close to network stuff as setting a proxy is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I;m starting to lean towards@n5y 's argument. Not specifically we need to protect users from early mistakes, but that additional kwarg adding should be explicit. That way we can reduce the warnings.
The option to addapi_kwargs
to every bot method which will be added to the data_dict silently. and removing**kwargs
seems good to me.
Bibo-Joshi commentedMay 13, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just noticed that the doc strings of the file types Edit: Done |
# Conflicts:#telegram/bot.py#telegram/utils/request.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Great change! I love this solution and I thank you for putting this much effort into it. It looks way better now, great stuff.
* 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
* 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
* 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 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
* 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 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
* 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 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
Uh oh!
There was an error while loading.Please reload this page.
Closes#1918
api_kwargs
to APIapi_kwargs
not being guaranteed to work. I put this on top ofBot
rather than on every function as the latter seemed a waste of space to me.base_url
is added inBot._post
instead of every functiondata.update(api_kwargs)
called inBot._post
instead of every functionset_sticker_set_thumb
on the flyNote: I removed a part of
Bot.set_webhook
that was intended for backwards compatibility, as it used**kwargs
. However, git blame tells me that it's 4 years old and from API 2.3.1 (?). So I thinks it's fair to say that it's not needed anymore.