Closed onecrayon closed 5 months ago
Literally seconds after posting this I stumbled across #588 after trying slightly different keywords; the existing msgspec.structs.force_setattr
perfectly addresses my needs. Apologies for the noise in your inbox!
Question
I am trying to normalize a piece of data in a
frozen=True
Struct class. I figured the most sensible place to do this was in__post_init__
but received this error:A bit of searching pulled up this StackOverflow answer: https://stackoverflow.com/a/54119384/38666 so I modified my code to look something like:
But that raised a new error:
Is there an officially-recommended way to go about this? The other good suggestion in that StackOverflow thread was to use a cached property, but this isn't appropriate for my use case because I'm normalizing data rather than generating a new property value (the source and the end name are the same).