Yeah, I was just discussing this with someone in IRC, and I appreciate an example of it in the wild.
I agree there's some wiggle room with what "initialized in a class body" means when it comes to dataclasses.
I see several interpretations there, and I would strongly prefer feedback from typing folks, particularly since they would be responsible for implementing any Final default_factory exceptions.
On the implementation side this does complicate things a bit depending on specifics. Are Final default_factory fields real fields or pseudo-fields? (i.e. are they returned by dataclasses.fields()?) Depending on how this works dataclasses might need a bit more refactoring than I'd be the right person for, but I'm still willing to give it a shot. |