Skip to content

Commit

Permalink
fix: RegistrableMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemDoum committed Jul 29, 2024
1 parent ed0e5be commit b562980
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions icij-worker/icij_worker/utils/registrable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -126,15 +126,17 @@ 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
@property
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
Expand Down

0 comments on commit b562980

Please sign in to comment.