mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
Use cached fn to get settings
This commit is contained in:
parent
bbb5658781
commit
ac7964a7b4
@ -7,7 +7,7 @@ import typing as t
|
|||||||
from click.testing import Result
|
from click.testing import Result
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from toot import App, User, config, __version__
|
from toot import App, User, config, __version__
|
||||||
from toot.settings import load_settings
|
from toot.settings import get_settings
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
import typing_extensions as te
|
import typing_extensions as te
|
||||||
@ -33,7 +33,7 @@ def get_default_visibility() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def get_default_map():
|
def get_default_map():
|
||||||
settings = load_settings()
|
settings = get_settings()
|
||||||
common = settings.get("common", {})
|
common = settings.get("common", {})
|
||||||
commands = settings.get("commands", {})
|
commands = settings.get("commands", {})
|
||||||
return {**common, **commands}
|
return {**common, **commands}
|
||||||
|
@ -17,7 +17,7 @@ def get_settings_path():
|
|||||||
return join(get_config_dir(), TOOT_SETTINGS_FILE_NAME)
|
return join(get_config_dir(), TOOT_SETTINGS_FILE_NAME)
|
||||||
|
|
||||||
|
|
||||||
def load_settings() -> dict:
|
def _load_settings() -> dict:
|
||||||
# Used for testing without config file
|
# Used for testing without config file
|
||||||
if DISABLE_SETTINGS:
|
if DISABLE_SETTINGS:
|
||||||
return {}
|
return {}
|
||||||
@ -33,7 +33,7 @@ def load_settings() -> dict:
|
|||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def get_settings():
|
def get_settings():
|
||||||
return load_settings()
|
return _load_settings()
|
||||||
|
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
Loading…
Reference in New Issue
Block a user