Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

config: Use logic from zulip_tools, to support bools.

Alex Vandiver0f70ab76795e
diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py
index 8a42746eb11..1287fa354bc 100755
--- a/scripts/lib/zulip_tools.py
+++ b/scripts/lib/zulip_tools.py
@@ -588,7 +588,7 @@ def get_config(
config_file: configparser.RawConfigParser,
section: str,
key: str,
- default_value: None,
+ default_value: None = None,
) -> Optional[str]: ...
@overload
def get_config(
diff --git a/zproject/config.py b/zproject/config.py
index dbcac359a94..c4fdd35f8f4 100644
--- a/zproject/config.py
+++ b/zproject/config.py
@@ -1,6 +1,8 @@
import configparser
import os
-from typing import Optional, overload
+from typing import Optional, Union, overload
+
+from scripts.lib.zulip_tools import get_config as get_config_from_file
class ZulipSettingsError(Exception):
@@ -22,12 +24,12 @@ else:
secrets_file.read(os.path.join(DEPLOY_ROOT, "zproject/dev-secrets.conf"))
-@overload
-def get_secret(key: str, default_value: str, development_only: bool = False) -> str: ...
@overload
def get_secret(
- key: str, default_value: Optional[str] = None, development_only: bool = False
+ key: str, default_value: None = None, development_only: bool = False
) -> Optional[str]: ...
+@overload
+def get_secret(key: str, default_value: str, development_only: bool = False) -> str: ...
def get_secret(
key: str, default_value: Optional[str] = None, development_only: bool = False
) -> Optional[str]:
@@ -45,12 +47,16 @@ def get_mandatory_secret(key: str) -> str:
return secret
+@overload
+def get_config(section: str, key: str, default_value: None = None) -> Optional[str]: ...
@overload
def get_config(section: str, key: str, default_value: str) -> str: ...
@overload
-def get_config(section: str, key: str, default_value: Optional[str] = None) -> Optional[str]: ...
-def get_config(section: str, key: str, default_value: Optional[str] = None) -> Optional[str]:
- return config_file.get(section, key, fallback=default_value)
+def get_config(section: str, key: str, default_value: bool) -> bool: ...
+def get_config(
+ section: str, key: str, default_value: Union[str, bool, None] = None
+) -> Union[str, bool, None]:
+ return get_config_from_file(config_file, section, key, default_value)
def get_from_file_if_exists(path: str) -> str: