Title: Refactor Filters · Issue #2178 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: Refactor Filters · Issue #2178 · python-telegram-bot/python-telegram-bot
X Title: Refactor Filters · Issue #2178 · python-telegram-bot/python-telegram-bot
Description: Currently filters check updates via the __call__ method. When switching from function-based filters to class-based filters, this was mainly done to maintain backwards compatibility with filter(update). However with some of the new filter...
Open Graph Description: Currently filters check updates via the __call__ method. When switching from function-based filters to class-based filters, this was mainly done to maintain backwards compatibility with filter(upda...
X Description: Currently filters check updates via the __call__ method. When switching from function-based filters to class-based filters, this was mainly done to maintain backwards compatibility with filter(upda...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/2178
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Refactor Filters","articleBody":"Currently filters check updates via the `__call__` method. When switching from function-based filters to class-based filters, this was mainly done to maintain backwards compatibility with `filter(update)`. However with some of the new filters functionalities, this leads to ugly workarounds like\r\n\r\nhttps://github.com/python-telegram-bot/python-telegram-bot/blob/8e7c0d6976055f970cd16bab9a1fcea5da7135cd/telegram/ext/filters.py#L329-L350\r\n\r\nI therefore propose to refactor to something along the lines of\r\n\r\n```python\r\nclass BaseFilter:\r\n def __call__(self, *args, **kwargs):\r\n return self.__class__(*args, **kwargs)\r\n\r\n @abstractmethod\r\n def check_update(update/method):\r\n ...\r\n```\r\n\r\nThis matches the `Handler.check_update` interface and allows for filters having a custom `__init__`, wich can still be called through instances of those filters.\r\n\r\nHowever, this is somewhat breaking: While `BaseFilter.__call__` is undocumented, people might still have `Filters.existing_filter(update)` somewhere within their custom filters. So *maybe* this is better suited for a major release. ","author":{"url":"https://github.com/Bibo-Joshi","@type":"Person","name":"Bibo-Joshi"},"datePublished":"2020-11-03T20:54:39Z","url":"https://github.com/python-telegram-bot/python-telegram-bot/issues/2178"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5270e0ed-ba76-4bf3-d6bd-f67c7fc94ea1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1C4:3B07B3:18EC019:1F3FC14:6B026CB2 |
| html-safe-nonce | 86e2d52723f712e18d813318b0732e0f7f0128085e35d0cdb6287aa88a8172ec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUM0OjNCMDdCMzoxOEVDMDE5OjFGM0ZDMTQ6NkIwMjZDQjIiLCJ2aXNpdG9yX2lkIjoiOTA4Mjg1MjY2MTYxODk2MTU4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fe159ef31f44efee2eb7c58154b5935e3b3f5de6a51078ebdf4ac54d5937a7a0 |
| hovercard-subject-tag | issue:735628537 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-telegram-bot/python-telegram-bot/2178/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb071d663b8b42bd94e9226bfd25b4d5398f1d312cd1838e63bd5160087505f1/python-telegram-bot/python-telegram-bot/issues/2178 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb071d663b8b42bd94e9226bfd25b4d5398f1d312cd1838e63bd5160087505f1/python-telegram-bot/python-telegram-bot/issues/2178 |
| og:image:alt | Currently filters check updates via the __call__ method. When switching from function-based filters to class-based filters, this was mainly done to maintain backwards compatibility with filter(upda... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Bibo-Joshi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git |
| octolytics-dimension-user_id | 16178365 |
| octolytics-dimension-user_login | python-telegram-bot |
| octolytics-dimension-repository_id | 38696925 |
| octolytics-dimension-repository_nwo | python-telegram-bot/python-telegram-bot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38696925 |
| octolytics-dimension-repository_network_root_nwo | python-telegram-bot/python-telegram-bot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width