|
10 | 10 |
|
11 | 11 | from __future__ import annotations
|
12 | 12 |
|
13 |
| -from typing import Callable, ClassVar, Generic, TypeVar, cast |
| 13 | +from typing import Any, Callable, ClassVar, Generic, TypeVar, cast |
14 | 14 |
|
15 | 15 | from guidellm.utils.auto_importer import AutoImporterMixin
|
16 | 16 |
|
|
19 | 19 |
|
20 | 20 | RegistryObjT = TypeVar("RegistryObjT")
|
21 | 21 | """Generic type variable for objects managed by the registry system."""
|
22 |
| -RegisterT = TypeVar("RegisterT") |
| 22 | +RegisterT = TypeVar("RegisterT", bound=type) # Must be bound to type to ensure __name__ is available. |
23 | 23 | """Generic type variable for the args and return values within the registry."""
|
24 | 24 |
|
25 | 25 |
|
@@ -62,7 +62,7 @@ class TokenProposal(RegistryMixin):
|
62 | 62 | :cvar registry_populated: Track whether auto-discovery has completed
|
63 | 63 | """
|
64 | 64 |
|
65 |
| - registry: ClassVar[dict[str, RegistryObjT] | None] = None |
| 65 | + registry: ClassVar[dict[str, Any] | None] = None |
66 | 66 | registry_auto_discovery: ClassVar[bool] = False
|
67 | 67 | registry_populated: ClassVar[bool] = False
|
68 | 68 |
|
@@ -209,6 +209,8 @@ def get_registered_object(cls, name: str) -> RegistryObjT | None:
|
209 | 209 | if name in cls.registry:
|
210 | 210 | return cls.registry[name]
|
211 | 211 |
|
212 |
| - lower_key_map = {key.lower(): key for key in cls.registry} |
| 212 | + for k, v in cls.registry.items(): |
| 213 | + if name.lower() == k.lower(): |
| 214 | + return v |
213 | 215 |
|
214 |
| - return cls.registry.get(lower_key_map.get(name.lower())) |
| 216 | + return None # Not found |
0 commit comments