Refine Python CI

Add lint environment to `deltachat-rpc-client/`
and set line length to 120, same as in `python/`.

Switch from flake8 to ruff.

Fix ruff warnings.
This commit is contained in:
link2xt
2023-01-19 00:31:39 +00:00
parent ef6f252842
commit fac7b064b4
41 changed files with 312 additions and 345 deletions

View File

@@ -15,5 +15,5 @@ if __name__ == "__main__":
p,
"-w",
workspacedir,
]
],
)

View File

@@ -216,7 +216,7 @@ def test_fetch_existing(acfactory, lp, mvbox_move):
# would also find the "Sent" folder, but it would be too late:
# The sentbox thread, started by `start_io()`, would have seen that there is no
# ConfiguredSentboxFolder and do nothing.
acfactory._acsetup.start_configure(ac1, reconfigure=True)
acfactory._acsetup.start_configure(ac1)
acfactory.bring_accounts_online()
assert_folders_configured(ac1)

View File

@@ -32,7 +32,7 @@ def test_basic_imap_api(acfactory, tmpdir):
imap2.shutdown()
@pytest.mark.ignored
@pytest.mark.ignored()
def test_configure_generate_key(acfactory, lp):
# A slow test which will generate new keys.
acfactory.remove_preconfigured_keys()
@@ -510,7 +510,7 @@ def test_send_and_receive_message_markseen(acfactory, lp):
idle2.wait_for_seen()
lp.step("1")
for i in range(2):
for _i in range(2):
ev = ac1._evtracker.get_matching("DC_EVENT_MSG_READ")
assert ev.data1 > const.DC_CHAT_ID_LAST_SPECIAL
assert ev.data2 > const.DC_MSG_ID_LAST_SPECIAL
@@ -529,7 +529,7 @@ def test_send_and_receive_message_markseen(acfactory, lp):
pass # mark_seen_messages() has generated events before it returns
def test_moved_markseen(acfactory, lp):
def test_moved_markseen(acfactory):
"""Test that message already moved to DeltaChat folder is marked as seen."""
ac1 = acfactory.new_online_configuring_account()
ac2 = acfactory.new_online_configuring_account(mvbox_move=True)
@@ -553,7 +553,7 @@ def test_moved_markseen(acfactory, lp):
ac2.mark_seen_messages([msg])
uid = idle2.wait_for_seen()
assert len([a for a in ac2.direct_imap.conn.fetch(AND(seen=True, uid=U(uid, "*")))]) == 1
assert len(list(ac2.direct_imap.conn.fetch(AND(seen=True, uid=U(uid, "*"))))) == 1
def test_message_override_sender_name(acfactory, lp):
@@ -832,7 +832,7 @@ def test_send_first_message_as_long_unicode_with_cr(acfactory, lp):
lp.sec("sending multi-line non-unicode message from ac1 to ac2")
text1 = (
"hello\nworld\nthis is a very long message that should be"
+ " wrapped using format=flowed and unwrapped on the receiver"
" wrapped using format=flowed and unwrapped on the receiver"
)
msg_out = chat.send_text(text1)
assert not msg_out.is_encrypted()
@@ -894,7 +894,7 @@ def test_dont_show_emails(acfactory, lp):
message in Drafts that is moved to Sent later
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
@@ -908,7 +908,7 @@ def test_dont_show_emails(acfactory, lp):
message in Sent
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
@@ -922,7 +922,7 @@ def test_dont_show_emails(acfactory, lp):
Unknown message in Spam
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
@@ -936,7 +936,7 @@ def test_dont_show_emails(acfactory, lp):
Unknown & malformed message in Spam
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
@@ -950,7 +950,7 @@ def test_dont_show_emails(acfactory, lp):
Unknown & malformed message in Spam
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
@@ -964,7 +964,7 @@ def test_dont_show_emails(acfactory, lp):
Actually interesting message in Spam
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
@@ -978,7 +978,7 @@ def test_dont_show_emails(acfactory, lp):
Unknown message in Junk
""".format(
ac1.get_config("configured_addr")
ac1.get_config("configured_addr"),
),
)
@@ -1710,7 +1710,7 @@ def test_system_group_msg_from_blocked_user(acfactory, lp):
assert contact.is_blocked()
chat_on_ac2.remove_contact(ac1)
ac1._evtracker.get_matching("DC_EVENT_CHAT_MODIFIED")
assert not ac1.get_self_contact() in chat_on_ac1.get_contacts()
assert ac1.get_self_contact() not in chat_on_ac1.get_contacts()
def test_set_get_group_image(acfactory, data, lp):
@@ -1784,7 +1784,7 @@ def test_connectivity(acfactory, lp):
lp.sec(
"Test that after calling start_io(), maybe_network() and waiting for `all_work_done()`, "
+ "all messages are fetched"
"all messages are fetched",
)
ac1.direct_imap.select_config_folder("inbox")
@@ -2146,7 +2146,7 @@ def test_group_quote(acfactory, lp):
@pytest.mark.parametrize(
"folder,move,expected_destination,",
("folder", "move", "expected_destination"),
[
(
"xyz",
@@ -2298,7 +2298,7 @@ class TestOnlineConfigureFails:
def test_invalid_password(self, acfactory):
configdict = acfactory.get_next_liveconfig()
ac1 = acfactory.get_unconfigured_account()
ac1.update_config(dict(addr=configdict["addr"], mail_pw="123"))
ac1.update_config({"addr": configdict["addr"], "mail_pw": "123"})
configtracker = ac1.configure()
configtracker.wait_progress(500)
configtracker.wait_progress(0)

View File

@@ -15,7 +15,7 @@ from deltachat.tracker import ImexFailed
@pytest.mark.parametrize(
"msgtext,res",
("msgtext", "res"),
[
(
"Member Me (tmp1@x.org) removed by tmp2@x.org.",
@@ -108,7 +108,7 @@ class TestOfflineAccountBasic:
def test_update_config(self, acfactory):
ac1 = acfactory.get_unconfigured_account()
ac1.update_config(dict(mvbox_move=False))
ac1.update_config({"mvbox_move": False})
assert ac1.get_config("mvbox_move") == "0"
def test_has_savemime(self, acfactory):
@@ -229,11 +229,11 @@ class TestOfflineContact:
class TestOfflineChat:
@pytest.fixture
@pytest.fixture()
def ac1(self, acfactory):
return acfactory.get_pseudo_configured_account()
@pytest.fixture
@pytest.fixture()
def chat1(self, ac1):
return ac1.create_contact("some1@example.org", name="some1").create_chat()
@@ -257,7 +257,7 @@ class TestOfflineChat:
assert chat2.id == chat1.id
assert chat2.get_name() == chat1.get_name()
assert chat1 == chat2
assert not (chat1 != chat2)
assert not chat1.__ne__(chat2)
assert chat1 != chat3
for ichat in ac1.get_chats():
@@ -450,7 +450,7 @@ class TestOfflineChat:
assert msg.filemime == "image/png"
@pytest.mark.parametrize(
"fn,typein,typeout",
("fn", "typein", "typeout"),
[
("r", None, "application/octet-stream"),
("r.txt", None, "text/plain"),
@@ -458,7 +458,7 @@ class TestOfflineChat:
("r.txt", "image/png", "image/png"),
],
)
def test_message_file(self, ac1, chat1, data, lp, fn, typein, typeout):
def test_message_file(self, chat1, data, lp, fn, typein, typeout):
lp.sec("sending file")
fp = data.get_path(fn)
msg = chat1.send_file(fp, typein)
@@ -694,7 +694,7 @@ class TestOfflineChat:
chat1.set_draft(None)
assert chat1.get_draft() is None
def test_qr_setup_contact(self, acfactory, lp):
def test_qr_setup_contact(self, acfactory):
ac1 = acfactory.get_pseudo_configured_account()
ac2 = acfactory.get_pseudo_configured_account()
qr = ac1.get_setup_contact_qr()

View File

@@ -93,7 +93,7 @@ def test_empty_context():
capi.lib.dc_context_unref(ctx)
def test_dc_close_events(tmpdir, acfactory):
def test_dc_close_events(acfactory):
ac1 = acfactory.get_unconfigured_account()
# register after_shutdown function