magic-filter
What it is and what it does
magic-filter is a lightweight Python library that lets you build filters using dynamic attribute access and a fluent syntax. Instead of writing nested conditionals or lambda functions, you construct filter expressions by accessing attributes on a special filter object, then apply those expressions to check or filter data. The library has no runtime dependencies and supports Python 3.7 through 3.11.
The package is in alpha status and has been dormant since late 2023, so it is stable for existing use cases but should not be expected to receive active maintenance or new features. It carries permissive licensing and is commonly associated with the aiogram ecosystem.
Use it for:
- Build declarative filters for message routing in Telegram bot handlers without writing nested conditionals.
- Validate object attributes against multiple conditions using a readable, expression-like syntax.
- Create reusable filter expressions that can be composed and applied to different data structures.
- Filter collections of objects by attribute values using a fluent API instead of list comprehensions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a filter mechanism based on dynamic attribute access that enables declarative filtering of objects using a fluent, expression-like syntax.
Yes, if you need declarative filtering and are comfortable with dormant maintenance. The package is stable, has no dependencies, and carries permissive licensing. It is well-suited for attribute-based filtering tasks where readability matters more than active development. Do not expect bug fixes or new features.
Install
magic-filter on PyPI
pip
pip install magic-filteruv
uv add magic-filterpoetry
poetry add magic-filterInstalling magic-filter
Before you install
Low friction installation with no runtime dependencies. Maintenance is dormant—last commit was 2023-09-25—so expect no active bug fixes or feature development, though the package is stable enough for existing use.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute it freely with minimal restrictions.
Quickstart
pip install magic-filter
from magic_filter import F
filter_expr = F.name == 'example'
result = filter_expr.check({'name': 'example'})
Verify before relying
- Exact semantics and typical use patterns beyond 'dynamic attribute getter' are not detailed in the fact sheet.
- Whether this is primarily for data validation, query building, or both remains unclear from the excerpt.
- How the package is typically used in practice beyond the aiogram ecosystem.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,048 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,019,202/month — #2,786 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: magic_filter-1.0.12-py3-none-any.whl
Keywords: filter, magic, validation
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
fastapi-filterAdds declarative filtering, sorting, and…
permissive · top 15,000 on PyPI
django-filterDjango-filter adds dynamic QuerySet filtering…
permissive · top 5,000 on PyPI
oelint-parserParses BitBake recipe files and provides…
permissive · top 15,000 on PyPI
djangorestframework-filtersExtends Django REST Framework with advanced…
permissive · top 15,000 on PyPI
mongo-query-matchProvides a MongoDB-like query language for…
unclear · top 15,000 on PyPI
magicattrProvides nested attribute access and…
permissive · top 5,000 on PyPI
cerbos-sqlalchemyConverts Cerbos authorization query plans into…
permissive · top 15,000 on PyPI
craft-partsCraft Parts provides a declarative framework…
unclear · top 15,000 on PyPI
jmespathJMESPath is a query language for extracting and…
permissive · top 100 on PyPI
sqlalchemy-filtersAdds filtering, sorting, and pagination…
permissive · top 15,000 on PyPI