AstraLuma on Nostr: Today in Python, I'm going to do dynamic class and metaclass stuff. It's going to be ...
Today in Python, I'm going to do dynamic class and metaclass stuff. It's going to be hilarious shenanigans.
But I'm having to be really clever, because:
* I want to avoid redundant-feeling declarations (registration decorator and required fields parent class)
* attrs might replace the class with a changeling
* I want static analysis to keep working
So far, I think I need a custom property descriptor, a metaclass, and some dynamic subclassing to make it work.
#Python
Published at
2024-11-08 17:30:38Event JSON
{
"id": "fad5eefe2da187066524e064c03d644f082333e1154bdc93ee4ffac47e7c730b",
"pubkey": "2be6621693eb5f1c4e3d0265f6cbcab31da9c422992bb173b817e33800e6483a",
"created_at": 1731087038,
"kind": 1,
"tags": [
[
"proxy",
"https://tacobelllabs.net/@astraluma/113448520185662448",
"web"
],
[
"t",
"python"
],
[
"proxy",
"https://tacobelllabs.net/users/astraluma/statuses/113448520185662448",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://tacobelllabs.net/users/astraluma/statuses/113448520185662448",
"pink.momostr"
],
[
"-"
]
],
"content": "Today in Python, I'm going to do dynamic class and metaclass stuff. It's going to be hilarious shenanigans. \n\nBut I'm having to be really clever, because: \n\n* I want to avoid redundant-feeling declarations (registration decorator and required fields parent class) \n* attrs might replace the class with a changeling\n* I want static analysis to keep working\n\nSo far, I think I need a custom property descriptor, a metaclass, and some dynamic subclassing to make it work. \n\n#Python",
"sig": "46243d521b4cd0e4a7a301ef4a2d499ec211ec3874b490efa37120488e83b86dfe2b8e5743c4acedbd92e64f5c19d8f4504c846091ba7c81266643ad8feb2d17"
}