From d10c5fed3e305e992c55d375d3975dab3e40580a Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Fri, 7 Jul 2023 12:17:36 +0200 Subject: [PATCH] Add type hints for get_setting --- toot/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/toot/settings.py b/toot/settings.py index 3b0a07a..90d4443 100644 --- a/toot/settings.py +++ b/toot/settings.py @@ -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