ominfra 0.0.0.dev133__py3-none-any.whl → 0.0.0.dev135__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -734,6 +734,13 @@ class PolymorphicObjMarshaler(ObjMarshaler):
734
734
  impls_by_ty: ta.Mapping[type, Impl]
735
735
  impls_by_tag: ta.Mapping[str, Impl]
736
736
 
737
+ @classmethod
738
+ def of(cls, impls: ta.Iterable[Impl]) -> 'PolymorphicObjMarshaler':
739
+ return cls(
740
+ {i.ty: i for i in impls},
741
+ {i.tag: i for i in impls},
742
+ )
743
+
737
744
  def marshal(self, o: ta.Any) -> ta.Any:
738
745
  impl = self.impls_by_ty[type(o)]
739
746
  return {impl.tag: impl.m.marshal(o)}
@@ -821,7 +828,7 @@ def _make_obj_marshaler(
821
828
  ) -> ObjMarshaler:
822
829
  if isinstance(ty, type):
823
830
  if abc.ABC in ty.__bases__:
824
- impls = [ # type: ignore
831
+ return PolymorphicObjMarshaler.of([ # type: ignore
825
832
  PolymorphicObjMarshaler.Impl(
826
833
  ity,
827
834
  ity.__qualname__,
@@ -829,11 +836,7 @@ def _make_obj_marshaler(
829
836
  )
830
837
  for ity in deep_subclasses(ty)
831
838
  if abc.ABC not in ity.__bases__
832
- ]
833
- return PolymorphicObjMarshaler(
834
- {i.ty: i for i in impls},
835
- {i.tag: i for i in impls},
836
- )
839
+ ])
837
840
 
838
841
  if issubclass(ty, enum.Enum):
839
842
  return EnumObjMarshaler(ty)
@@ -0,0 +1 @@
1
+ # @omlish-lite