mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
python: use pyright
This commit is contained in:
@@ -55,3 +55,5 @@ line-length = 120
|
|||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
profile = "black"
|
profile = "black"
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
|||||||
@@ -463,9 +463,10 @@ class Chat:
|
|||||||
:returns: None
|
:returns: None
|
||||||
"""
|
"""
|
||||||
contact = self.account.get_contact(obj)
|
contact = self.account.get_contact(obj)
|
||||||
ret = lib.dc_remove_contact_from_chat(self.account._dc_context, self.id, contact.id)
|
if contact:
|
||||||
if ret != 1:
|
ret = lib.dc_remove_contact_from_chat(self.account._dc_context, self.id, contact.id)
|
||||||
raise ValueError(f"could not remove contact {contact!r} from chat")
|
if ret != 1:
|
||||||
|
raise ValueError("could not remove contact {contact!r} from chat")
|
||||||
|
|
||||||
def get_contacts(self):
|
def get_contacts(self):
|
||||||
"""get all contacts for this chat.
|
"""get all contacts for this chat.
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class DirectImap:
|
|||||||
log("Message", msg.uid, "has empty body")
|
log("Message", msg.uid, "has empty body")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
path = pathlib.Path(str(dir)).joinpath("IMAP", self.logid, imapfolder)
|
path = pathlib.Path(str(dir)).joinpath("IMAP", str(self.logid), imapfolder)
|
||||||
path.mkdir(parents=True, exist_ok=True)
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
fn = path.joinpath(str(msg.uid))
|
fn = path.joinpath(str(msg.uid))
|
||||||
fn.write_bytes(body)
|
fn.write_bytes(body)
|
||||||
|
|||||||
@@ -111,11 +111,12 @@ class FFIEventTracker:
|
|||||||
while True:
|
while True:
|
||||||
yield self.get(timeout=timeout, check_error=check_error)
|
yield self.get(timeout=timeout, check_error=check_error)
|
||||||
|
|
||||||
def get_matching(self, event_name_regex, check_error=True, timeout=None):
|
def get_matching(self, event_name_regex, check_error=True, timeout=None) -> FFIEvent:
|
||||||
rex = re.compile(f"^(?:{event_name_regex})$")
|
rex = re.compile(f"^(?:{event_name_regex})$")
|
||||||
for ev in self.iter_events(timeout=timeout, check_error=check_error):
|
for ev in self.iter_events(timeout=timeout, check_error=check_error):
|
||||||
if rex.match(ev.name):
|
if rex.match(ev.name):
|
||||||
return ev
|
return ev
|
||||||
|
assert False
|
||||||
|
|
||||||
def get_info_contains(self, regex: str) -> FFIEvent:
|
def get_info_contains(self, regex: str) -> FFIEvent:
|
||||||
rex = re.compile(regex)
|
rex = re.compile(regex)
|
||||||
@@ -123,6 +124,7 @@ class FFIEventTracker:
|
|||||||
ev = self.get_matching("DC_EVENT_INFO")
|
ev = self.get_matching("DC_EVENT_INFO")
|
||||||
if rex.search(ev.data2):
|
if rex.search(ev.data2):
|
||||||
return ev
|
return ev
|
||||||
|
assert False
|
||||||
|
|
||||||
def get_info_regex_groups(self, regex, check_error=True):
|
def get_info_regex_groups(self, regex, check_error=True):
|
||||||
rex = re.compile(regex)
|
rex = re.compile(regex)
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ def data(request):
|
|||||||
fn = os.path.join(path, *bn.split("/"))
|
fn = os.path.join(path, *bn.split("/"))
|
||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
return fn
|
return fn
|
||||||
print(f"WARNING: path does not exist: {fn!r}")
|
print(f"WARNING: path does not exist: {request!r}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def read_path(self, bn, mode="r"):
|
def read_path(self, bn, mode="r"):
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
from filecmp import cmp
|
from filecmp import cmp
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ def wait_msg_delivered(account, msg_list):
|
|||||||
msg_list.remove((ev.data1, ev.data2))
|
msg_list.remove((ev.data1, ev.data2))
|
||||||
|
|
||||||
|
|
||||||
def wait_msgs_changed(account, msgs_list):
|
def wait_msgs_changed(account, msgs_list: list[tuple[int, Optional[int]]]):
|
||||||
"""wait for one or more MSGS_CHANGED events to match msgs_list contents."""
|
"""wait for one or more MSGS_CHANGED events to match msgs_list contents."""
|
||||||
account.log(f"waiting for msgs_list={msgs_list}")
|
account.log(f"waiting for msgs_list={msgs_list}")
|
||||||
msgs_list = list(msgs_list)
|
msgs_list = list(msgs_list)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ envlist =
|
|||||||
lint
|
lint
|
||||||
mypy
|
mypy
|
||||||
auditwheels
|
auditwheels
|
||||||
|
pyright
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
commands =
|
commands =
|
||||||
@@ -25,6 +26,7 @@ deps =
|
|||||||
pytest-xdist
|
pytest-xdist
|
||||||
pdbpp
|
pdbpp
|
||||||
requests
|
requests
|
||||||
|
pyright: pyright
|
||||||
|
|
||||||
[testenv:.pkg]
|
[testenv:.pkg]
|
||||||
passenv =
|
passenv =
|
||||||
@@ -68,6 +70,10 @@ deps =
|
|||||||
commands =
|
commands =
|
||||||
mypy --no-incremental src/
|
mypy --no-incremental src/
|
||||||
|
|
||||||
|
[testenv:pyright]
|
||||||
|
commands =
|
||||||
|
pyright
|
||||||
|
|
||||||
[testenv:doc]
|
[testenv:doc]
|
||||||
changedir=doc
|
changedir=doc
|
||||||
deps =
|
deps =
|
||||||
|
|||||||
Reference in New Issue
Block a user