python-attrs / python-attrs/attrs
evolve() and attr.ib(init=False, default="foo")
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
As pointed out in https://github.com/ericvsmith/dataclasses/issues/42#issuecomment-330198369 attr.evolve() behaves rather weird if an attribute has
- init=False,
- a default/
__attrs_post_init__, and - attribute(s) are modified on the instance.
The new resulting object will always have the default value.
I think I can live with that limitation if we document it and it's probably a good reason to resolve #207 with sticking assoc around with a better name?
Giving it further thought, the raison d'être for evolve are immutable objects…so I think it's fine to just document this edge case and leave it be?
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 reading the attr.evolve documentation and the linked discussion about init=False attributes with defaults or attrs_post_init. Confirm the behavior described in the issue, then document this limitation and its interaction with modified instance attributes; done means the edge case is clearly explained to users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100