summary refs log tree commit diff
path: root/synapse/_scripts/update_synapse_database.py
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-04-08 15:00:12 +0100
committerGitHub <noreply@github.com>2022-04-08 14:00:12 +0000
commit0cd182f296ce44dbaafc9a56f9af2183d21a9443 (patch)
tree489d74a056240b0c92ec44dec0cc2a2e8ec8ed26 /synapse/_scripts/update_synapse_database.py
parentStop maintaining a list of lint targets in `lint.sh` (#12420) (diff)
downloadsynapse-0cd182f296ce44dbaafc9a56f9af2183d21a9443.tar.xz
Make `synapse._scripts` pass typechecks (#12421)
Diffstat (limited to 'synapse/_scripts/update_synapse_database.py')
-rwxr-xr-xsynapse/_scripts/update_synapse_database.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/synapse/_scripts/update_synapse_database.py b/synapse/_scripts/update_synapse_database.py

index f43676afaa..736f58836d 100755 --- a/synapse/_scripts/update_synapse_database.py +++ b/synapse/_scripts/update_synapse_database.py
@@ -16,22 +16,27 @@ import argparse import logging import sys +from typing import cast import yaml from matrix_common.versionstring import get_distribution_version_string -from twisted.internet import defer, reactor +from twisted.internet import defer, reactor as reactor_ from synapse.config.homeserver import HomeServerConfig from synapse.metrics.background_process_metrics import run_as_background_process from synapse.server import HomeServer from synapse.storage import DataStore +from synapse.types import ISynapseReactor +# Cast safety: Twisted does some naughty magic which replaces the +# twisted.internet.reactor module with a Reactor instance at runtime. +reactor = cast(ISynapseReactor, reactor_) logger = logging.getLogger("update_database") class MockHomeserver(HomeServer): - DATASTORE_CLASS = DataStore + DATASTORE_CLASS = DataStore # type: ignore [assignment] def __init__(self, config, **kwargs): super(MockHomeserver, self).__init__( @@ -85,12 +90,10 @@ def main(): args = parser.parse_args() - logging_config = { - "level": logging.DEBUG if args.v else logging.INFO, - "format": "%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(message)s", - } - - logging.basicConfig(**logging_config) + logging.basicConfig( + level=logging.DEBUG if args.v else logging.INFO, + format="%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(message)s", + ) # Load, process and sanity-check the config. hs_config = yaml.safe_load(args.database_config)