Skip to content
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

Refactor handling of default_quote #1965

Merged
merged 14 commits into from
Jul 19, 2020
Merged

Refactor handling of default_quote #1965

merged 14 commits into from
Jul 19, 2020

Conversation

Bibo-Joshi
Copy link
Member

@Bibo-Joshi Bibo-Joshi commented May 26, 2020

Right now, bot.defaults.quote is passed through the json data when decoding an update for it to be stored in Message.default_quote. As @n5y pointed out offline, it would be cleaner to just use Message.bot.defaults.quote. This is, what this PR does.

To not break backwards compatibility, I left some optional default_quote args in the Webhook classes untouched and also kept default_quote as argument for Message (with a warning that it will override the bots settings). That's discussable though, as nobody should have actually used that …

Closes parts of #1797

Copy link
Member Author

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes is Message lead to errors when trying to access message._default_quote after unplicking. Need to make that backwards compatible.

Also, we might wanna mark the default_quote arg (maybe even the attribute, too) for deprecation.

@Bibo-Joshi Bibo-Joshi changed the base branch from master to v13 June 6, 2020 10:55
@Bibo-Joshi
Copy link
Member Author

Latests commits

  • Remove Message.default_quote all along, making it a breaking change. Hence, changed PR to the new v13 branch. Also, this way, unpickling is no problem anymore.
  • Makes sure that a bots default values are un/pickled along with it.
    • upside: the unpickled bot of an unpickled Message still has the correct default quote setting
    • downside: the unpickled bot is not the same as the updaters one. If the defaults for the updater are changed, the unpickled bots don't change accordingly. Then again, this is not really new, i.e. the behaviour is the same for the token. maybe that should at least be documented somewhere …

@Bibo-Joshi
Copy link
Member Author

We should postpone this after #1994

@Bibo-Joshi Bibo-Joshi added this to the 13.0 milestone Jun 12, 2020
@Bibo-Joshi
Copy link
Member Author

Also, we could/should raise a warning, if both bot and defaults are passed to Updater, as after this the defaults passed to the updater have no effect.

* 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
# Conflicts:
#	telegram/bot.py
Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 122 to 123
warnings.warn('Passing defaults to an Updater has no effect, if a Bot is passed, '
'too. Pass it to the Bot instead.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
warnings.warn('Passing defaults to an Updater has no effect, if a Bot is passed, '
'too. Pass it to the Bot instead.',
warnings.warn('Passing defaults to an Updater has no effect when a Bot is passed'
'as well. Pass them to the Bot instead.',

@Poolitzer
Copy link
Member

Poolitzer commented Jul 19, 2020

In here are a lot of changes which I reviewed in different PRs, like the refactor of the jobqueue, the api kwargs or the persistence part. Is that intended?

@Bibo-Joshi Bibo-Joshi changed the base branch from v13 to master July 19, 2020 14:25
@Bibo-Joshi Bibo-Joshi changed the base branch from master to v13 July 19, 2020 14:25
# Conflicts:
#	telegram/bot.py
#	tests/test_persistence.py
@Bibo-Joshi Bibo-Joshi merged commit 8e94d0d into v13 Jul 19, 2020
@Bibo-Joshi Bibo-Joshi deleted the defaults branch July 19, 2020 15:47
Bibo-Joshi added a commit that referenced this pull request Aug 13, 2020
* 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
Bibo-Joshi added a commit that referenced this pull request Aug 16, 2020
* 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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants