Add type hints to app.__init__.

This commit is contained in:
Patrick Cloke 2021-11-09 16:02:23 -05:00
parent 70384c7907
commit 8c8c4f9aff
3 changed files with 11 additions and 8 deletions

View file

@ -25,7 +25,6 @@ exclude = (?x)
^(
|synapse/_scripts/register_new_matrix_user.py
|synapse/_scripts/review_recent_signups.py
|synapse/app/__init__.py
|synapse/storage/databases/__init__.py
|synapse/storage/databases/main/__init__.py
|synapse/storage/databases/main/account_data.py

View file

@ -13,6 +13,7 @@
# limitations under the License.
import logging
import sys
from typing import Container
from synapse import python_dependencies # noqa: E402
@ -27,7 +28,9 @@ except python_dependencies.DependencyException as e:
sys.exit(1)
def check_bind_error(e, address, bind_addresses):
def check_bind_error(
e: Exception, address: str, bind_addresses: Container[str]
) -> None:
"""
This method checks an exception occurred while binding on 0.0.0.0.
If :: is specified in the bind addresses a warning is shown.
@ -38,9 +41,9 @@ def check_bind_error(e, address, bind_addresses):
When binding on 0.0.0.0 after :: this can safely be ignored.
Args:
e (Exception): Exception that was caught.
address (str): Address on which binding was attempted.
bind_addresses (list): Addresses on which the service listens.
e: Exception that was caught.
address: Address on which binding was attempted.
bind_addresses: Addresses on which the service listens.
"""
if address == "0.0.0.0" and "::" in bind_addresses:
logger.warning(

View file

@ -27,6 +27,7 @@ from typing import (
Any,
Awaitable,
Callable,
Collection,
Dict,
Iterable,
List,
@ -256,7 +257,7 @@ def listen_metrics(bind_addresses: Iterable[str], port: int) -> None:
def listen_manhole(
bind_addresses: Iterable[str],
bind_addresses: Collection[str],
port: int,
manhole_settings: ManholeConfig,
manhole_globals: dict,
@ -280,7 +281,7 @@ def listen_manhole(
def listen_tcp(
bind_addresses: Iterable[str],
bind_addresses: Collection[str],
port: int,
factory: ServerFactory,
# mypy can't figure out what the default reactor is.
@ -306,7 +307,7 @@ def listen_tcp(
def listen_ssl(
bind_addresses: Iterable[str],
bind_addresses: Collection[str],
port: int,
factory: ServerFactory,
context_factory: IOpenSSLContextFactory,