From 96146f51c07dd43f07b5c28cea1fe6baeeaeae2c Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 7 Apr 2022 09:21:05 -0400 Subject: [PATCH] config_dir_path is not optional. --- synapse/_scripts/review_recent_signups.py | 4 +--- synapse/config/_base.py | 5 +---- synapse/config/_base.pyi | 5 +---- synapse/config/key.py | 2 +- tests/config/test_registration_config.py | 24 +++++++++++++++++------ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/synapse/_scripts/review_recent_signups.py b/synapse/_scripts/review_recent_signups.py index e207f154f3aa..a935c50f426c 100644 --- a/synapse/_scripts/review_recent_signups.py +++ b/synapse/_scripts/review_recent_signups.py @@ -138,9 +138,7 @@ def main() -> None: config_args = parser.parse_args(sys.argv[1:]) config_files = find_config_files(search_paths=config_args.config_path) config_dict = read_config_files(config_files) - config.parse_config_dict( - config_dict, - ) + config.parse_config_dict(config_dict, "", "") since_ms = time.time() * 1000 - Config.parse_duration(config_args.since) exclude_users_with_email = config_args.exclude_emails diff --git a/synapse/config/_base.py b/synapse/config/_base.py index 8e19e2fc2668..179aa7ff887e 100644 --- a/synapse/config/_base.py +++ b/synapse/config/_base.py @@ -702,10 +702,7 @@ def load_or_generate_config( return obj def parse_config_dict( - self, - config_dict: Dict[str, Any], - config_dir_path: Optional[str] = None, - data_dir_path: Optional[str] = None, + self, config_dict: Dict[str, Any], config_dir_path: str, data_dir_path: str ) -> None: """Read the information from the config dict into this Config object. diff --git a/synapse/config/_base.pyi b/synapse/config/_base.pyi index 363d8b45545e..bd092f956dde 100644 --- a/synapse/config/_base.pyi +++ b/synapse/config/_base.pyi @@ -124,10 +124,7 @@ class RootConfig: @classmethod def invoke_all_static(cls, func_name: str, *args: Any, **kwargs: Any) -> None: ... def parse_config_dict( - self, - config_dict: Dict[str, Any], - config_dir_path: Optional[str] = ..., - data_dir_path: Optional[str] = ..., + self, config_dict: Dict[str, Any], config_dir_path: str, data_dir_path: str ) -> None: ... def generate_config( self, diff --git a/synapse/config/key.py b/synapse/config/key.py index 2f20575c3c52..ada65f6dd6e7 100644 --- a/synapse/config/key.py +++ b/synapse/config/key.py @@ -100,7 +100,7 @@ class KeyConfig(Config): section = "key" def read_config( - self, config: JsonDict, config_dir_path: Optional[str], **kwargs: Any + self, config: JsonDict, config_dir_path: str, **kwargs: Any ) -> None: # the signing key can be specified inline or in a separate file if "signing_key" in config: diff --git a/tests/config/test_registration_config.py b/tests/config/test_registration_config.py index 2acdb6ac6161..33d7b70e32ed 100644 --- a/tests/config/test_registration_config.py +++ b/tests/config/test_registration_config.py @@ -37,7 +37,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): "session_lifetime": "30m", "nonrefreshable_access_token_lifetime": "31m", **config_dict, - } + }, + "", + "", ) with self.assertRaises(ConfigError): @@ -46,7 +48,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): "session_lifetime": "30m", "refreshable_access_token_lifetime": "31m", **config_dict, - } + }, + "", + "", ) with self.assertRaises(ConfigError): @@ -55,7 +59,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): "session_lifetime": "30m", "refresh_token_lifetime": "31m", **config_dict, - } + }, + "", + "", ) # Then test all the fine conditions @@ -64,7 +70,9 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): "session_lifetime": "31m", "nonrefreshable_access_token_lifetime": "31m", **config_dict, - } + }, + "", + "", ) HomeServerConfig().parse_config_dict( @@ -72,11 +80,15 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): "session_lifetime": "31m", "refreshable_access_token_lifetime": "31m", **config_dict, - } + }, + "", + "", ) HomeServerConfig().parse_config_dict( - {"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict} + {"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict}, + "", + "", ) def test_refuse_to_start_if_open_registration_and_no_verification(self):