skrawcz opened a new pull request, #676:
URL: https://github.com/apache/burr/pull/676
Extend Condition.when() to support Django-style lookup operators via
double-underscore suffixes (e.g. when(age__gte=18), when(status__in=[...])).
Supported operators: eq, ne, gt, gte, lt, lte, in, notin, contains. Plain
key=value usage remains fully backward compatible.
Includes 43 new parametrized tests and updated transition docs.
## Changes
Improves `when(...)` expressiveness.
```
Basic equality (unchanged from original)::
when(foo="bar") # state["foo"] == "bar"
when(foo="bar", baz="qux") # state["foo"] == "bar" AND
state["baz"] == "qux"
Comparison operators via ``__`` suffix::
when(age__gt=18) # state["age"] > 18
when(age__gte=18) # state["age"] >= 18
when(age__lt=18) # state["age"] < 18
when(age__lte=18) # state["age"] <= 18
when(age__ne=0) # state["age"] != 0
when(age__eq=18) # state["age"] == 18 (explicit)
Membership operators::
when(status__in=["a", "b"]) # state["status"] in ["a", "b"]
when(status__notin=["x", "y"]) # state["status"] not in ["x",
"y"]
when(tags__contains="python") # "python" in state["tags"]
Multiple conditions are ANDed together::
when(age__gte=18, status="active") # age >= 18 AND status ==
"active"
```
## How I tested this
-[x] unit tets
## Notes
## Checklist
- [ ] PR has an informative and human-readable title (this will be pulled
into the release notes)
- [ ] Changes are limited to a single goal (no scope creep)
- [ ] Code passed the pre-commit check & code is left cleaner/nicer than
when first encountered.
- [ ] Any _change_ in functionality is tested
- [ ] New functions are documented (with a description, list of inputs, and
expected output)
- [ ] Placeholder code is flagged / future TODOs are captured in comments
- [ ] Project documentation has been updated if adding/changing
functionality.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]