From b22deceb00e8901c90b3c4799856d7cf609e852e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Mon, 12 Feb 2018 10:56:28 +0100 Subject: [PATCH] Mypy fixes. --- main.py | 2 +- matrix/api.py | 3 ++- matrix/colors.py | 2 +- matrix/config.py | 2 +- matrix/server.py | 16 ++++++++-------- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index a51f7a2..51bfa54 100644 --- a/main.py +++ b/main.py @@ -115,7 +115,7 @@ WEECHAT_SCRIPT_LICENSE = "ISC" # type: str def wrap_socket(server, file_descriptor): - # type: (MatrixServer, int) -> socket.socket + # type: (MatrixServer, int) -> None sock = None # type: socket.socket temp_socket = socket.fromfd( diff --git a/matrix/api.py b/matrix/api.py index ac5db4f..3e307c1 100644 --- a/matrix/api.py +++ b/matrix/api.py @@ -53,6 +53,7 @@ class MatrixClient: access_token="", # type: str user_agent="" # type: str ): + # type: (...) -> None self.host = host self.user_agent = user_agent self.access_token = access_token @@ -101,7 +102,7 @@ class MatrixClient: return HttpRequest(RequestType.GET, self.host, path) def room_send_message(self, room_id, content, formatted_content=None): - # type: (str, Dict[str, str]) -> HttpRequest + # type: (str, str, str) -> HttpRequest query_parameters = {"access_token": self.access_token} body = { diff --git a/matrix/colors.py b/matrix/colors.py index 25c7e44..d9fc273 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -39,7 +39,7 @@ FormattedString = namedtuple( class Formatted(): def __init__(self, substrings): - # type: List[FormattedString] -> None + # type: (List[FormattedString]) -> None self.substrings = substrings diff --git a/matrix/config.py b/matrix/config.py index efb6ddc..ba7975b 100644 --- a/matrix/config.py +++ b/matrix/config.py @@ -149,7 +149,7 @@ def matrix_config_init(config_file): def matrix_config_read(config): - # type: () -> bool + # type: (str) -> bool return_code = W.config_read(config) if return_code == W.WEECHAT_CONFIG_READ_OK: return True diff --git a/matrix/server.py b/matrix/server.py index b89c671..cfe8436 100644 --- a/matrix/server.py +++ b/matrix/server.py @@ -40,7 +40,7 @@ from matrix.api import MatrixClient class MatrixServer: # pylint: disable=too-many-instance-attributes def __init__(self, name, config_file): - # type: (str, weechat, weechat.config) -> None + # type: (str, weechat.config) -> None self.name = name # type: str self.user_id = "" self.address = "" # type: str @@ -223,12 +223,12 @@ class MatrixServer: strerr = error.strerror if error.strerror else "Unknown reason" strerr = errno + strerr - message = ("{prefix}Error while writing to " - "socket: {error}").format( - prefix=W.prefix("network"), - error=strerr) + error_message = ("{prefix}Error while writing to " + "socket: {error}").format( + prefix=W.prefix("network"), + error=strerr) - server_buffer_prnt(self, message) + server_buffer_prnt(self, error_message) server_buffer_prnt( self, ("{prefix}matrix: disconnecting from server...").format( @@ -266,7 +266,7 @@ class MatrixServer: self.current_message.send_time = time.time() self.receive_queue.append(self.current_message) - self.send_buffer = "" + self.send_buffer = b"" self.current_message = None @@ -324,7 +324,7 @@ class MatrixServer: pass def disconnect(self, reconnect=True): - # type: (MatrixServer) -> None + # type: (bool) -> None if self.fd_hook: W.unhook(self.fd_hook)