@overload
async def get_provider_config_value(
- self, instance_id: str, key: str, *, return_type: type[_ConfigValueT] = ...
+ self,
+ instance_id: str,
+ key: str,
+ *,
+ default: _ConfigValueT,
+ return_type: type[_ConfigValueT] = ...,
+ ) -> _ConfigValueT: ...
+
+ @overload
+ async def get_provider_config_value(
+ self,
+ instance_id: str,
+ key: str,
+ *,
+ default: ConfigValueType = ...,
+ return_type: type[_ConfigValueT] = ...,
) -> _ConfigValueT: ...
@overload
async def get_provider_config_value(
- self, instance_id: str, key: str, *, return_type: None = ...
+ self,
+ instance_id: str,
+ key: str,
+ *,
+ default: ConfigValueType = ...,
+ return_type: None = ...,
) -> ConfigValueType: ...
@api_command("config/providers/get_value")
instance_id: str,
key: str,
*,
+ default: ConfigValueType = None,
return_type: type[_ConfigValueT | ConfigValueType] | None = None,
) -> _ConfigValueT | ConfigValueType:
"""
:param instance_id: The provider instance ID.
:param key: The config key to retrieve.
+ :param default: Optional default value to return if key is not found.
:param return_type: Optional type hint for type inference (e.g., str, int, bool).
Note: This parameter is used purely for static type checking and does not
perform runtime type validation. Callers are responsible for ensuring the
if (cached_value := self._value_cache.get(cache_key)) is not None:
return cached_value
conf = await self.get_provider_config(instance_id)
+ if key not in conf.values:
+ if default is not None:
+ return default
+ msg = f"Config key {key} not found for provider {instance_id}"
+ raise KeyError(msg)
val = (
conf.values[key].value
if conf.values[key].value is not None
key: str,
unpack_splitted_values: Literal[True],
*,
+ default: ConfigValueType = ...,
return_type: type[_ConfigValueT] | None = ...,
) -> tuple[str, ...] | list[tuple[str, ...]]: ...
key: str,
unpack_splitted_values: Literal[False] = False,
*,
+ default: _ConfigValueT,
return_type: type[_ConfigValueT] = ...,
) -> _ConfigValueT: ...
key: str,
unpack_splitted_values: Literal[False] = False,
*,
+ default: ConfigValueType = ...,
+ return_type: type[_ConfigValueT] = ...,
+ ) -> _ConfigValueT: ...
+
+ @overload
+ async def get_player_config_value(
+ self,
+ player_id: str,
+ key: str,
+ unpack_splitted_values: Literal[False] = False,
+ *,
+ default: ConfigValueType = ...,
return_type: None = ...,
) -> ConfigValueType: ...
player_id: str,
key: str,
unpack_splitted_values: bool = False,
+ *,
+ default: ConfigValueType = None,
return_type: type[_ConfigValueT | ConfigValueType] | None = None,
) -> _ConfigValueT | ConfigValueType | tuple[str, ...] | list[tuple[str, ...]]:
"""
:param player_id: The player ID.
:param key: The config key to retrieve.
:param unpack_splitted_values: Whether to unpack multi-value config entries.
+ :param default: Optional default value to return if key is not found.
:param return_type: Optional type hint for type inference (e.g., str, int, bool).
Note: This parameter is used purely for static type checking and does not
perform runtime type validation. Callers are responsible for ensuring the
specified type matches the actual config value type.
"""
conf = await self.get_player_config(player_id)
+ if key not in conf.values:
+ if default is not None:
+ return default
+ msg = f"Config key {key} not found for player {player_id}"
+ raise KeyError(msg)
if unpack_splitted_values:
return conf.values[key].get_splitted_values()
return (
@overload
async def get_core_config_value(
- self, domain: str, key: str, *, return_type: type[_ConfigValueT] = ...
+ self,
+ domain: str,
+ key: str,
+ *,
+ default: _ConfigValueT,
+ return_type: type[_ConfigValueT] = ...,
) -> _ConfigValueT: ...
@overload
async def get_core_config_value(
- self, domain: str, key: str, *, return_type: None = ...
+ self,
+ domain: str,
+ key: str,
+ *,
+ default: ConfigValueType = ...,
+ return_type: type[_ConfigValueT] = ...,
+ ) -> _ConfigValueT: ...
+
+ @overload
+ async def get_core_config_value(
+ self,
+ domain: str,
+ key: str,
+ *,
+ default: ConfigValueType = ...,
+ return_type: None = ...,
) -> ConfigValueType: ...
@api_command("config/core/get_value")
domain: str,
key: str,
*,
+ default: ConfigValueType = None,
return_type: type[_ConfigValueT | ConfigValueType] | None = None,
) -> _ConfigValueT | ConfigValueType:
"""
:param domain: The core controller domain.
:param key: The config key to retrieve.
+ :param default: Optional default value to return if key is not found.
:param return_type: Optional type hint for type inference (e.g., str, int, bool).
Note: This parameter is used purely for static type checking and does not
perform runtime type validation. Callers are responsible for ensuring the
specified type matches the actual config value type.
"""
conf = await self.get_core_config(domain)
+ if key not in conf.values:
+ if default is not None:
+ return default
+ msg = f"Config key {key} not found for core controller {domain}"
+ raise KeyError(msg)
return (
conf.values[key].value
if conf.values[key].value is not None
for param_name in handler.signature.parameters:
if param_name == "self":
continue
+ # Skip return_type parameter (used only for type hints)
+ if param_name == "return_type":
+ continue
param_type = handler.type_hints.get(param_name, Any)
# Skip Any types as they don't provide useful schema information
if param_type is not Any and str(param_type) != "typing.Any":
for param_name, param in handler.signature.parameters.items():
if param_name == "self":
continue
+ # Skip return_type parameter (used only for type hints)
+ if param_name == "return_type":
+ continue
is_required = param.default is inspect.Parameter.empty
param_type = handler.type_hints.get(param_name, Any)
type_str = str(param_type)
for param_name in handler.signature.parameters:
if param_name == "self":
continue
+ # Skip return_type parameter (used only for type hints)
+ if param_name == "return_type":
+ continue
param_type = handler.type_hints.get(param_name, Any)
if param_type is not Any and str(param_type) != "typing.Any":
_get_type_schema(param_type, schemas)
for param_name, param in handler.signature.parameters.items():
if param_name == "self":
continue
+ # Skip return_type parameter (used only for type hints)
+ if param_name == "return_type":
+ continue
param_type = handler.type_hints.get(param_name, Any)
is_required = param.default is inspect.Parameter.empty