python-attrs / python-attrs/attrs
Add support for accessing the instance in converters
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
Currently it's not possible to access the current instance in a converter, except you use decorators. I currently define converters automatically based on their type with the field_transformer hook, unfortunately this only provides the class.
This can be implemented in multiple ways.
- Enforcing the self argument in converters. This would cause a breaking change)
- Only passing the instance if the user provides 2 arguments
- Passing the instance in
field_transformer
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 converter invocation path and the field_transformer hook, then compare how decorators currently expose the instance. Decide which of the proposed calling conventions is intended before changing behavior. Done means converters can access the current instance through a defined, tested interface without leaving the API choice ambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100