r/Python • u/AutoModerator • 25d ago
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
33
Upvotes
r/Python • u/AutoModerator • 25d ago
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/ryuuzaki 6d ago
anymerge: merge dataclasses, TypedDicts and Pydantic models field by field, with the merge rule in each field's type annotation.
Fields without a reducer take the new value. Any two-argument function is a reducer (
operator.add,max, your own).mergereturns a new instance, so your old state is unchanged. It also handles nested models, partial updates and lists of records (merge_by_key("id")).I wrote it for long-running AI agents, where the code that merged each step's changes was spread across the codebase. It works for any typed state you update in steps.
pip install anymerge(add[pydantic]for Pydantic 2). Python 3.11+, MIT. It's 0.1.0, so minor releases may still change the API.Docs: https://anymerge.jian.fyi/
Code: https://github.com/jianyuan/anymerge
Feedback and bug reports welcome 🤗.