Mypy fixes.
This commit is contained in:
parent
7ab59ec636
commit
b22deceb00
5 changed files with 13 additions and 12 deletions
2
main.py
2
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(
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -39,7 +39,7 @@ FormattedString = namedtuple(
|
|||
|
||||
class Formatted():
|
||||
def __init__(self, substrings):
|
||||
# type: List[FormattedString] -> None
|
||||
# type: (List[FormattedString]) -> None
|
||||
self.substrings = substrings
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue