Refactor handling of message vs update filters #2032
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
BaseFilter.__call__
an abstract method and implement two subclasses:MessageFilter
andUpdateFilter
, each of which will take care of passing the right object tofilter()
update_filter
, make the filters inherit from those.BaseFilter
toMessage/UpdateFilter
in order to make typing even more clear. This makes it breaking, butBaseFilter
toMessageHandler
is not too bad. Leavingupdate_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 filtersCloses #1595 and #1596