Additional type hints for config module. (#11465)

This adds some misc. type hints to helper methods used
in the `synapse.config` module.
This commit is contained in:
Patrick Cloke 2021-12-01 07:28:23 -05:00 committed by GitHub
parent a265fbd397
commit f44d729d4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 129 additions and 99 deletions

View file

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import itertools
import logging
import os.path
@ -27,6 +28,7 @@ from netaddr import AddrFormatError, IPNetwork, IPSet
from twisted.conch.ssh.keys import Key
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
from synapse.types import JsonDict
from synapse.util.module_loader import load_module
from synapse.util.stringutils import parse_and_validate_server_name
@ -1223,7 +1225,7 @@ class ServerConfig(Config):
% locals()
)
def read_arguments(self, args):
def read_arguments(self, args: argparse.Namespace) -> None:
if args.manhole is not None:
self.manhole = args.manhole
if args.daemonize is not None:
@ -1232,7 +1234,7 @@ class ServerConfig(Config):
self.print_pidfile = args.print_pidfile
@staticmethod
def add_arguments(parser):
def add_arguments(parser: argparse.ArgumentParser) -> None:
server_group = parser.add_argument_group("server")
server_group.add_argument(
"-D",
@ -1274,14 +1276,16 @@ class ServerConfig(Config):
)
def is_threepid_reserved(reserved_threepids, threepid):
def is_threepid_reserved(
reserved_threepids: List[JsonDict], threepid: JsonDict
) -> bool:
"""Check the threepid against the reserved threepid config
Args:
reserved_threepids([dict]) - list of reserved threepids
threepid(dict) - The threepid to test for
reserved_threepids: List of reserved threepids
threepid: The threepid to test for
Returns:
boolean Is the threepid undertest reserved_user
Is the threepid undertest reserved_user
"""
for tp in reserved_threepids:
@ -1290,7 +1294,9 @@ def is_threepid_reserved(reserved_threepids, threepid):
return False
def read_gc_thresholds(thresholds):
def read_gc_thresholds(
thresholds: Optional[List[Any]],
) -> Optional[Tuple[int, int, int]]:
"""Reads the three integer thresholds for garbage collection. Ensures that
the thresholds are integers if thresholds are supplied.
"""