Split public and private config/driver APIs (#6024)

This commit is contained in:
Jakub Kuczys
2025-01-27 00:25:53 +01:00
committed by GitHub
parent b13b1f8f16
commit f962aeb7b8
6 changed files with 46 additions and 30 deletions

View File

@@ -35,7 +35,6 @@ log = logging.getLogger("red.config")
_T = TypeVar("_T")
_config_cache = weakref.WeakValueDictionary()
_retrieved = weakref.WeakSet()
class ConfigMeta(type):
@@ -65,14 +64,6 @@ class ConfigMeta(type):
return instance
def get_latest_confs() -> Tuple["Config"]:
global _retrieved
ret = set(_config_cache.values()) - set(_retrieved)
_retrieved |= ret
# noinspection PyTypeChecker
return tuple(ret)
class _ValueCtxManager(Awaitable[_T], AsyncContextManager[_T]): # pylint: disable=duplicate-bases
"""Context manager implementation of config values.
@@ -1529,16 +1520,6 @@ class Config(metaclass=ConfigMeta):
return self._lock_cache.setdefault(id_data, asyncio.Lock())
async def migrate(cur_driver_cls: Type[BaseDriver], new_driver_cls: Type[BaseDriver]) -> None:
"""Migrate from one driver type to another."""
# Get custom group data
core_conf = Config.get_core_conf(allow_old=True)
core_conf.init_custom("CUSTOM_GROUPS", 2)
all_custom_group_data = await core_conf.custom("CUSTOM_GROUPS").all()
await cur_driver_cls.migrate_to(new_driver_cls, all_custom_group_data)
def _str_key_dict(value: Dict[Any, _T]) -> Dict[str, _T]:
"""
Recursively casts all keys in the given `dict` to `str`.