Skip to content

Refactor: don't pass attr, obj, data to fields (de)serialize methods#2963

Draft
lafrech wants to merge 10 commits intodevfrom
rework_ser_deser
Draft

Refactor: don't pass attr, obj, data to fields (de)serialize methods#2963
lafrech wants to merge 10 commits intodevfrom
rework_ser_deser

Conversation

@lafrech
Copy link
Copy Markdown
Member

@lafrech lafrech commented May 3, 2026

#2039 is a long standing issue I've been wanting to address for a while but it implies a lot of changes that can hardly be done incrementally so I never got down to it.

[Disclaimer: The company I work for wants us to leverage AI power because everyone does it (FOMO) so we asked for Claude tokens and I tried agent coding on our projects to give management feedback about it and I figured why not try it on this issue as well. Obviously, it is not as simple as telling the tool to fix #2039. It took me a few tries to get the steps in the right order. And although I was supervising, there may be a few hallucinations I haven't spotted yet. The tool was not always clever at guessing what I didn't tell, but it helped me facing the fear of rewriting all calls to serialization functions in lib and tests.]

I'm sharing this as it is a nice POC. It still needs to be polished around the edges and there may be possibilities for further improvements, but some of them could be done later. Changes certainly need to be double-checked (but this would also be true if I had done all this manually, TBH). Consider it an illustration of what I have in mind.

The [de|]serialization_getter arguments added to Field could be added in MA4 while deprecating the use of Function/Method to do fancy accessing. The rest is breaking changes that would have to wait until 5.0.

Happy to get feedback before doing any more work on this.

@lafrech
Copy link
Copy Markdown
Member Author

lafrech commented May 4, 2026

I don't remember the rationale for not having mypy run in pre-commit.

@sloria
Copy link
Copy Markdown
Member

sloria commented May 4, 2026

only skimmed the code changes (haven't read the tests), but this is looking really nice. i do think this is the right direction overall. maybe rename to load_getter and dump_getter for consistency.

The [de|]serialization_getter arguments added to Field could be added in MA4 while deprecating the use of Function/Method to do fancy accessing. The rest is breaking changes that would have to wait until 5.0.

👍 that seems like a good release plan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Don't pass attr, obj, data to fields (de)serialize methods

2 participants