python-attrs / python-attrs/attrs
API semantics for deep nested evolve calls
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
When trying to evolve a frozen object at a deep level, there is a lot of boilerplate, e.g.,:
foo = attr.evolve(
foo,
bar=attr.evolve(
foo.bar,
baz=attr.evolve(
foo.bar.baz,
qux='whew!'
)
)
)
Scala has a similar problem, being that immutable data classes is a normal thing in that language. There is a Scala library developed helped to solve that problem: https://www.optics.dev/Monocle/
Maybe it would be useful to have those sort of semantics for updating frozen attr objects,e.g.:
foo = attr.focus(foo, Foo.bar.baz.qux).modify('yay!')
Any thoughts?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing attr.evolve API and the nested frozen-object examples in the issue; no file or test entry point is named. Read the linked Monocle project for comparison, then define the proposed focus and modify semantics, supported paths, and acceptance criteria before assessing implementation scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100