This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Additional type hints for config module. #11465
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
68e1b9a
Add missing type hints to appservice.
clokep 77b855c
Add missing type hints to SSO config modules.
clokep 93f73be
Add type hints to caches.
clokep 24c9d69
Add type hints to add_arguments and read_arguments.
clokep 6b8e8a6
Add missing type hints to logger.
clokep 28a293b
Add missing type hints to server helpers.
clokep 67976b5
Add missing type hints to repository.
clokep f61c961
Newsfragment
clokep f1eb99e
Review comments.
clokep 8e129c8
Lint
clokep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add missing type hints to `synapse.config` module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # Copyright 2014-2016 OpenMarket Ltd | ||
| # Copyright 2020 The Matrix.org Foundation C.I.C. | ||
| # Copyright 2020-2021 The Matrix.org Foundation C.I.C. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
|
|
@@ -12,6 +12,7 @@ | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import argparse | ||
| import logging | ||
| import os | ||
|
|
||
|
|
@@ -119,7 +120,7 @@ def __init__(self, *args, **kwargs): | |
|
|
||
| self.databases = [] | ||
|
|
||
| def read_config(self, config, **kwargs): | ||
| def read_config(self, config, **kwargs) -> None: | ||
clokep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # We *experimentally* support specifying multiple databases via the | ||
| # `databases` key. This is a map from a label to database config in the | ||
| # same format as the `database` config option, plus an extra | ||
|
|
@@ -163,12 +164,12 @@ def read_config(self, config, **kwargs): | |
| self.databases = [DatabaseConnectionConfig("master", database_config)] | ||
| self.set_databasepath(database_path) | ||
|
|
||
| def generate_config_section(self, data_dir_path, **kwargs): | ||
| def generate_config_section(self, data_dir_path, **kwargs) -> str: | ||
| return DEFAULT_CONFIG % { | ||
| "database_path": os.path.join(data_dir_path, "homeserver.db") | ||
| } | ||
|
|
||
| def read_arguments(self, args): | ||
| def read_arguments(self, args: argparse.Namespace) -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aside: I wish there was a way for mypy to know which attributes would be available on
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean if you could note what type of arguments exist in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking more that I'd like mypy to be able to deduce which args would exist, but an explict annotation would be good too! |
||
| """ | ||
| Cases for the cli input: | ||
| - If no databases are configured and no database_path is set, raise. | ||
|
|
@@ -194,15 +195,15 @@ def read_arguments(self, args): | |
| else: | ||
| logger.warning(NON_SQLITE_DATABASE_PATH_WARNING) | ||
|
|
||
| def set_databasepath(self, database_path): | ||
| def set_databasepath(self, database_path: str) -> None: | ||
|
|
||
| if database_path != ":memory:": | ||
| database_path = self.abspath(database_path) | ||
|
|
||
| self.databases[0].config["args"]["database"] = database_path | ||
|
|
||
| @staticmethod | ||
| def add_arguments(parser): | ||
| def add_arguments(parser: argparse.ArgumentParser) -> None: | ||
| db_group = parser.add_argument_group("database") | ||
| db_group.add_argument( | ||
| "-d", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.