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 message vs update filters #2032

Merged
merged 2 commits into from
Jul 28, 2020
Merged

Conversation

Bibo-Joshi
Copy link
Member

As mentioned offline:

update_filter is a bit unsatisfactory to me. E.g. it leads to irritation with users (see #1595) and makes typing hard (see #1920)

What this PR does is:

  • Make BaseFilter.__call__ an abstract method and implement two subclasses: MessageFilter and UpdateFilter, each of which will take care of passing the right object to filter()
  • instead of setting update_filter, make the filters inherit from those.
  • Also move the abstract filter() method from BaseFilter to Message/UpdateFilter in order to make typing even more clear. This makes it breaking, but
    • v13 is breaking anyway
    • switching inheritance from BaseFilter to MessageHandler is not too bad. Leaving update_filter = True won't even hurt …

Offline I also mentioned dropping data_filter, but that was nonsense, as we need that for the short circuit logic of the filters

Closes #1595 and #1596

@Bibo-Joshi Bibo-Joshi added this to the 13.0 milestone Jul 27, 2020
Copy link
Member

@jsmnbom jsmnbom left a comment

Choose a reason for hiding this comment

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

I'm very tired, but found a couple of thing that might need changes. Mostly just looks good tho!

telegram/ext/filters.py Outdated Show resolved Hide resolved
telegram/ext/filters.py Show resolved Hide resolved
tests/test_filters.py Outdated Show resolved Hide resolved
telegram/ext/filters.py Outdated Show resolved Hide resolved
@Bibo-Joshi Bibo-Joshi requested a review from jsmnbom July 27, 2020 20:48
@Bibo-Joshi Bibo-Joshi removed the request for review from Poolitzer July 28, 2020 06:36
@Bibo-Joshi Bibo-Joshi merged commit 48fca54 into v13 Jul 28, 2020
@Bibo-Joshi Bibo-Joshi deleted the refactor-update-filters branch July 28, 2020 07:10
Bibo-Joshi added a commit that referenced this pull request Aug 13, 2020
* Refactor handling of message vs update filters

* address review
Bibo-Joshi added a commit that referenced this pull request Aug 16, 2020
* Refactor handling of message vs update filters

* address review
@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