Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add missing type hints to config classes. #12402

Merged
merged 9 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
config_dir_path is not optional.
  • Loading branch information
clokep committed Apr 7, 2022
commit 96146f51c07dd43f07b5c28cea1fe6baeeaeae2c
4 changes: 1 addition & 3 deletions synapse/_scripts/review_recent_signups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions synapse/config/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 1 addition & 4 deletions synapse/config/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 18 additions & 6 deletions tests/config/test_registration_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -64,19 +70,25 @@ 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(
{
"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):
Expand Down