Add type hints for get_setting

This commit is contained in:
Ivan Habunek 2023-07-07 12:17:36 +02:00
parent f1e4c8d68f
commit d10c5fed3e
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 5 additions and 2 deletions

View File

@ -5,7 +5,7 @@ from functools import lru_cache
from os.path import exists, join
from tomlkit import parse
from toot import get_config_dir
from typing import Optional, Type
from typing import Optional, Type, TypeVar
DISABLE_SETTINGS = False
@ -36,7 +36,10 @@ def get_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,
e.g. "commands.post.editor" which will correspond to the "editor" setting