add proxy for the first part and try to develop the second part

This commit is contained in:
Pierre Geeraert
2025-12-03 12:08:56 +00:00
parent 6c34d510e5
commit 460f18d85a
1095 changed files with 358799 additions and 5 deletions
@@ -0,0 +1,31 @@
from collections.abc import Mapping
from typing import Any
__REGISTRY: Mapping[str, Any] = vars()
class _Synthetic:
def __reduce__(self):
return (
synthesize(type(self).__name__, type(self).__bases__),
(),
vars(self),
)
def synthesize(name, bases):
typename = f'{__name__}.{name}'
if not isinstance(bases, tuple):
bases = (bases,)
if _Synthetic not in bases:
bases += (_Synthetic,)
constructor = __REGISTRY.get(typename)
if not constructor:
constructor = type(name, bases, {})
typename = constructor.__name__
__REGISTRY[typename] = constructor
return constructor