mirror of
https://github.com/ihabunek/toot
synced 2025-02-15 19:40:42 +01:00
Add type hints for get_setting
This commit is contained in:
parent
f1e4c8d68f
commit
d10c5fed3e
@ -5,7 +5,7 @@ from functools import lru_cache
|
|||||||
from os.path import exists, join
|
from os.path import exists, join
|
||||||
from tomlkit import parse
|
from tomlkit import parse
|
||||||
from toot import get_config_dir
|
from toot import get_config_dir
|
||||||
from typing import Optional, Type
|
from typing import Optional, Type, TypeVar
|
||||||
|
|
||||||
|
|
||||||
DISABLE_SETTINGS = False
|
DISABLE_SETTINGS = False
|
||||||
@ -36,7 +36,10 @@ def get_settings():
|
|||||||
return load_settings()
|
return load_settings()
|
||||||
|
|
||||||
|
|
||||||
def get_setting(key: str, type: Type, default=None):
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
|
def get_setting(key: str, type: Type[T], default: Optional[T] = None) -> Optional[T]:
|
||||||
"""
|
"""
|
||||||
Get a setting value. The key should be a dot-separated string,
|
Get a setting value. The key should be a dot-separated string,
|
||||||
e.g. "commands.post.editor" which will correspond to the "editor" setting
|
e.g. "commands.post.editor" which will correspond to the "editor" setting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user