--- id: rule-engine version: "5.0.2" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # rule-engine — A lightweight, optionally typed expression language with a custom grammar for matching arbitrary Python objects. License: permissive · Maintenance: active · Downloads: 448.3K/mo ## What it is and what it does Rule Engine is a domain-specific language (DSL) for writing matching rules as strings in Python code. You define rules using a custom grammar similar to Python syntax, then apply them to dictionaries or objects to test whether they match. The language supports optional type annotations to catch errors early, regular expression matching on strings, datetime values, and compound types like lists, dicts, and sets. Typical usage involves creating a Rule object with an expression string, optionally providing a typed Context to validate symbol names and operations, then calling the rule's matching method on data objects. It's designed for scenarios where you need to express filtering or matching logic in a declarative, user-friendly way rather than writing Python conditionals directly. The package includes a debug REPL for experimentation. Use it for: - Filter records in a database or API response based on user-defined rule expressions without writing custom Python code - Implement a rules engine for workflow automation where business logic is expressed as strings and evaluated at runtime - Validate incoming data against typed rule sets to ensure only objects matching specific criteria proceed - Build a query language for applications where end users need to define matching criteria without Python knowledge - Match log entries or events against rule expressions for alerting or log aggregation systems ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Rule Engine provides a lightweight, custom expression language for evaluating rules against Python objects, with optional type hinting and support for regex matching, datetime handling, and compound data types. Yes. Rule Engine is actively maintained, has no known vulnerabilities, low install friction, and solves a clear problem: declarative rule evaluation without writing Python code. The permissive BSD-3-Clause license poses no restrictions. Install if you need to evaluate user-defined or data-driven matching logic; skip if you're writing simple hardcoded conditionals. ## Install pip install rule-engine uv add rule-engine poetry add rule-engine ## Installing rule-engine Before you install: Low install friction with a single runtime dependency (python-dateutil). Active maintenance with a recent release 37 days ago and ongoing repository activity. License in practice: BSD-3-Clause permissive license allows commercial and private use without restriction. Quickstart: pip install rule-engine import rule_engine rule = rule_engine.Rule('first_name == "Luke" and email =~ ".*@rebels.org$"') rule.matches({'first_name': 'Luke', 'email': 'luke@rebels.org'}) Requires Python 3.10 or later; Version 6.0 will drop Python 3.10 support. Verify before relying: - Performance characteristics when evaluating large rule sets or complex expressions against many objects - Thread-safety guarantees beyond the documented claim in the description excerpt ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 448.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags rule evaluation engine, expression language matching, pattern matching rules, typed rule expressions, regex rule matching, conditional rule engine, data filtering rules, dsl, rule-matching, expression-evaluation [View on SkillFed](https://skillfed.io/packages/rule-engine) · [View on PyPI](https://pypi.org/project/rule-engine/)