From b5629800e7bdf4a327058625ea6dda9cf7cefcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Doumouro?= Date: Mon, 29 Jul 2024 10:27:17 +0200 Subject: [PATCH] fix: RegistrableMixin --- icij-worker/icij_worker/utils/registrable.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/icij-worker/icij_worker/utils/registrable.py b/icij-worker/icij_worker/utils/registrable.py index ab74460e..ef6d8446 100644 --- a/icij-worker/icij_worker/utils/registrable.py +++ b/icij-worker/icij_worker/utils/registrable.py @@ -46,8 +46,8 @@ def register( cls, name: Optional[str] = None, exist_ok: bool = False ) -> Callable[[Type[_T]], Type[_T]]: # pylint: disable=protected-access - registry = Registrable._registry[cls] - registered_names = Registrable._registered_names[cls] + registry = RegistrableMixin._registry[cls] + registered_names = RegistrableMixin._registered_names[cls] def add_subclass_to_registry(subclass: Type[_T]) -> Type[_T]: registered_name = name @@ -88,9 +88,9 @@ def by_name(cls: Type[_RegistrableT], name: str) -> Callable[..., _RegistrableT] @classmethod def resolve_class_name(cls: Type[_RegistrableT], name: str) -> Type[_RegistrableT]: # pylint: disable=protected-access - sub_registry = Registrable._registry.get(cls, None) + sub_registry = RegistrableMixin._registry.get(cls, None) if sub_registry is None: - for k, v in Registrable._registry.items(): + for k, v in RegistrableMixin._registry.items(): if issubclass(cls, k): sub_registry = v break @@ -126,7 +126,7 @@ def resolve_class_name(cls: Type[_RegistrableT], name: str) -> Type[_Registrable @classmethod def list_available(cls) -> List[str]: # pylint: disable=protected-access - keys = list(Registrable._registry[cls].keys()) + keys = list(RegistrableMixin._registry[cls].keys()) return keys @classmethod @@ -134,7 +134,9 @@ def list_available(cls) -> List[str]: def registered_name(cls) -> str: for ( names - ) in Registrable._registered_names.values(): # pylint: disable=protected-access + ) in ( + RegistrableMixin._registered_names.values() + ): # pylint: disable=protected-access name = names.get(cls) if name is not None: return name