python-attrs / python-attrs/attrs
Evolve converts/validates again not changed fields
Open
Nobody has claimed this yet.
Feature
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
Here's the usecase:
def decrypt_secret(value):
return ...
@attrs.frozen
class Settings:
user: str
pwd: str = attrs.field(converter=decrypt_secret)
sett = Settings(user="name", pwd=<encrypted_value>)
sett.pwd # already decrypted value
attrs.evolve(sett, user="name2")
This will fail, because it tries to decrypt already decrypted value, although the field pwd not changed at all.
Probably it is a wrong behaviour to convert/validate not changed fields.
Didn't find how to avoid converting/validating in this case.
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
The only entry point named is attrs.evolve; start by tracing its implementation and the existing tests around evolve, then reproduce the frozen Settings example. Done means evolving only user does not reconvert or revalidate unchanged pwd, with regression coverage for that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100