Fixed a few things mentioned in SonarCloud
All checks were successful
Analysis / SonarCloud (push) Successful in 40s
All checks were successful
Analysis / SonarCloud (push) Successful in 40s
This commit is contained in:
parent
4ee704b41e
commit
d20d07bb6a
@ -11,6 +11,8 @@ except ImportError:
|
||||
from ._utils import supports_argument
|
||||
from .sync._nested import nested_delete, nested_set
|
||||
|
||||
DEFAULT_CONFIG_LOCATION: str = "config.json"
|
||||
|
||||
|
||||
async def json_read(path: Union[str, Path]) -> Any:
|
||||
"""Read contents of a JSON file
|
||||
@ -43,7 +45,7 @@ async def json_write(data: Any, path: Union[str, Path]) -> None:
|
||||
|
||||
|
||||
async def config_get(
|
||||
key: str, *path: str, config_file: Union[str, Path] = "config.json"
|
||||
key: str, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||
) -> Any:
|
||||
"""Get a value of the config key by its path provided
|
||||
For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"`
|
||||
@ -83,7 +85,7 @@ async def config_get(
|
||||
|
||||
|
||||
async def config_set(
|
||||
key: str, value: Any, *path: str, config_file: Union[str, Path] = "config.json"
|
||||
key: str, value: Any, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||
) -> None:
|
||||
"""Set config's key by its path to the value
|
||||
|
||||
@ -99,14 +101,13 @@ async def config_set(
|
||||
await json_write(
|
||||
nested_set(await json_read(config_file), value, *(*path, key)), config_file
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
async def config_delete(
|
||||
key: str,
|
||||
*path: str,
|
||||
missing_ok: bool = False,
|
||||
config_file: Union[str, Path] = "config.json",
|
||||
config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION,
|
||||
) -> None:
|
||||
"""Set config's key by its path
|
||||
|
||||
|
@ -358,7 +358,8 @@ class PyroClient(Client):
|
||||
]
|
||||
|
||||
logger.info(
|
||||
"Registering commands %s with a default scope 'BotCommandScopeDefault'"
|
||||
"Registering commands %s with a default scope 'BotCommandScopeDefault'",
|
||||
commands
|
||||
)
|
||||
|
||||
await self.set_bot_commands(commands)
|
||||
|
@ -9,6 +9,8 @@ try:
|
||||
except ImportError:
|
||||
from json import dumps, loads
|
||||
|
||||
DEFAULT_CONFIG_LOCATION: str = "config.json"
|
||||
|
||||
|
||||
def json_read(path: Union[str, Path]) -> Any:
|
||||
"""Read contents of a JSON file
|
||||
@ -41,7 +43,7 @@ def json_write(data: Any, path: Union[str, Path]) -> None:
|
||||
|
||||
|
||||
def config_get(
|
||||
key: str, *path: str, config_file: Union[str, Path] = "config.json"
|
||||
key: str, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||
) -> Any:
|
||||
"""Get a value of the config key by its path provided
|
||||
For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"`
|
||||
@ -81,7 +83,7 @@ def config_get(
|
||||
|
||||
|
||||
def config_set(
|
||||
key: str, value: Any, *path: str, config_file: Union[str, Path] = "config.json"
|
||||
key: str, value: Any, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||
) -> None:
|
||||
"""Set config's key by its path to the value
|
||||
|
||||
@ -95,14 +97,13 @@ def config_set(
|
||||
* `KeyError`: Key is not found under path provided
|
||||
"""
|
||||
json_write(nested_set(json_read(config_file), value, *(*path, key)), config_file)
|
||||
return
|
||||
|
||||
|
||||
def config_delete(
|
||||
key: str,
|
||||
*path: str,
|
||||
missing_ok: bool = False,
|
||||
config_file: Union[str, Path] = "config.json",
|
||||
config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION,
|
||||
) -> None:
|
||||
"""Set config's key by its path
|
||||
|
||||
|
@ -6,10 +6,12 @@ from libbot._utils import supports_argument
|
||||
|
||||
|
||||
def func1(foo: str, bar: str):
|
||||
"""Dummy function with specific arguments"""
|
||||
pass
|
||||
|
||||
|
||||
def func2(foo: str):
|
||||
"""Dummy function with specific arguments"""
|
||||
pass
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user