From d727d85f6dc48d3beca4b90dec81c89775790aca Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 25 Aug 2023 20:57:44 +0000 Subject: [PATCH 1/3] chore(python): fix `ruff` 0.0.286 warnings --- python/src/deltachat/account.py | 2 +- python/src/deltachat/cutil.py | 2 +- python/tests/bench_test_setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 8272dc965..fde031564 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -427,7 +427,7 @@ class Account: assert dc_chatlist != ffi.NULL chatlist = [] - for i in range(0, lib.dc_chatlist_get_cnt(dc_chatlist)): + for i in range(lib.dc_chatlist_get_cnt(dc_chatlist)): chat_id = lib.dc_chatlist_get_chat_id(dc_chatlist, i) chatlist.append(Chat(self, chat_id)) return chatlist diff --git a/python/src/deltachat/cutil.py b/python/src/deltachat/cutil.py index ad9810219..f907166b9 100644 --- a/python/src/deltachat/cutil.py +++ b/python/src/deltachat/cutil.py @@ -15,7 +15,7 @@ def as_dc_charpointer(obj): def iter_array(dc_array_t, constructor: Callable[[int], T]) -> Generator[T, None, None]: - for i in range(0, lib.dc_array_get_cnt(dc_array_t)): + for i in range(lib.dc_array_get_cnt(dc_array_t)): yield constructor(lib.dc_array_get_id(dc_array_t, i)) diff --git a/python/tests/bench_test_setup.py b/python/tests/bench_test_setup.py index 5dc5e3877..ef750550f 100644 --- a/python/tests/bench_test_setup.py +++ b/python/tests/bench_test_setup.py @@ -15,6 +15,6 @@ class TestEmpty: def test_prepare_setup_measurings(self, acfactory): acfactory.get_online_accounts(BENCH_NUM) - @pytest.mark.parametrize("num", range(0, BENCH_NUM + 1)) + @pytest.mark.parametrize("num", range(BENCH_NUM + 1)) def test_setup_online_accounts(self, acfactory, num): acfactory.get_online_accounts(num) From 2635146328a95dbc7ac8cd3fd9a2ad56721932c9 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 4 Aug 2023 20:08:20 +0000 Subject: [PATCH 2/3] build: update to Zig 0.11.0 --- scripts/zig-musl-check.sh | 2 +- scripts/zig-rpc-server.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/zig-musl-check.sh b/scripts/zig-musl-check.sh index 1e4afd6db..78bdd7e09 100755 --- a/scripts/zig-musl-check.sh +++ b/scripts/zig-musl-check.sh @@ -11,7 +11,7 @@ unset RUSTFLAGS # Pin Rust version to avoid uncontrolled changes in the compiler and linker flags. export RUSTUP_TOOLCHAIN=1.70.0 -ZIG_VERSION=0.11.0-dev.2213+515e1c93e +ZIG_VERSION=0.11.0 # Download Zig rm -fr "$ZIG_VERSION" "zig-linux-x86_64-$ZIG_VERSION.tar.xz" diff --git a/scripts/zig-rpc-server.sh b/scripts/zig-rpc-server.sh index ee96905bb..359099b1e 100755 --- a/scripts/zig-rpc-server.sh +++ b/scripts/zig-rpc-server.sh @@ -10,7 +10,7 @@ unset RUSTFLAGS # Pin Rust version to avoid uncontrolled changes in the compiler and linker flags. export RUSTUP_TOOLCHAIN=1.70.0 -ZIG_VERSION=0.11.0-dev.2213+515e1c93e +ZIG_VERSION=0.11.0 # Download Zig rm -fr "$ZIG_VERSION" "zig-linux-x86_64-$ZIG_VERSION.tar.xz" From 87ffcaf03e543217f08c3aff623c25eefef3c183 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 25 Aug 2023 21:21:04 +0000 Subject: [PATCH 3/3] build: update to Rust 1.72.0 --- .github/workflows/ci.yml | 2 +- scripts/coredeps/install-rust.sh | 2 +- scripts/zig-musl-check.sh | 2 +- scripts/zig-rpc-server.sh | 2 +- src/configure.rs | 4 ++-- src/configure/auto_mozilla.rs | 2 +- src/html.rs | 16 ++++++++-------- src/mimeparser.rs | 16 ++++++++-------- src/plaintext.rs | 8 ++++---- src/provider.rs | 2 +- src/receive_imf.rs | 2 +- src/smtp.rs | 10 +++++----- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 010d32992..33fb07bb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: name: Lint Rust runs-on: ubuntu-latest env: - RUSTUP_TOOLCHAIN: 1.70.0 + RUSTUP_TOOLCHAIN: 1.72.0 steps: - uses: actions/checkout@v3 - name: Install rustfmt and clippy diff --git a/scripts/coredeps/install-rust.sh b/scripts/coredeps/install-rust.sh index 8181cc991..20e72611b 100755 --- a/scripts/coredeps/install-rust.sh +++ b/scripts/coredeps/install-rust.sh @@ -7,7 +7,7 @@ set -euo pipefail # # Avoid using rustup here as it depends on reading /proc/self/exe and # has problems running under QEMU. -RUST_VERSION=1.68.0 +RUST_VERSION=1.72.0 ARCH="$(uname -m)" test -f "/lib/libc.musl-$ARCH.so.1" && LIBC=musl || LIBC=gnu diff --git a/scripts/zig-musl-check.sh b/scripts/zig-musl-check.sh index 78bdd7e09..89c9b5bf6 100755 --- a/scripts/zig-musl-check.sh +++ b/scripts/zig-musl-check.sh @@ -9,7 +9,7 @@ set -e unset RUSTFLAGS # Pin Rust version to avoid uncontrolled changes in the compiler and linker flags. -export RUSTUP_TOOLCHAIN=1.70.0 +export RUSTUP_TOOLCHAIN=1.72.0 ZIG_VERSION=0.11.0 diff --git a/scripts/zig-rpc-server.sh b/scripts/zig-rpc-server.sh index 359099b1e..1f35b3fd1 100755 --- a/scripts/zig-rpc-server.sh +++ b/scripts/zig-rpc-server.sh @@ -8,7 +8,7 @@ set -e unset RUSTFLAGS # Pin Rust version to avoid uncontrolled changes in the compiler and linker flags. -export RUSTUP_TOOLCHAIN=1.70.0 +export RUSTUP_TOOLCHAIN=1.72.0 ZIG_VERSION=0.11.0 diff --git a/src/configure.rs b/src/configure.rs index 4ef4ed3e3..bb63c83d9 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -131,7 +131,7 @@ async fn on_configure_completed( ) -> Result<()> { if let Some(provider) = param.provider { if let Some(config_defaults) = &provider.config_defaults { - for def in config_defaults.iter() { + for def in config_defaults { if !context.config_exists(def.key).await? { info!(context, "apply config_defaults {}={}", def.key, def.value); context.set_config(def.key, Some(def.value)).await?; @@ -656,7 +656,7 @@ async fn try_smtp_one_param( }) } else { info!(context, "success: {}", inf); - smtp.disconnect().await; + smtp.disconnect(); Ok(()) } } diff --git a/src/configure/auto_mozilla.rs b/src/configure/auto_mozilla.rs index 505691814..617429f59 100644 --- a/src/configure/auto_mozilla.rs +++ b/src/configure/auto_mozilla.rs @@ -234,7 +234,7 @@ fn parse_serverparams(in_emailaddr: &str, xml_raw: &str) -> Result Some(Protocol::Imap), diff --git a/src/html.rs b/src/html.rs index 306ce2ae1..7124c0a1a 100644 --- a/src/html.rs +++ b/src/html.rs @@ -291,7 +291,7 @@ mod tests { let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap(); assert_eq!( parser.html, - r##" + r#" @@ -299,7 +299,7 @@ mod tests { This message does not have Content-Type nor Subject.

-"## +"# ); } @@ -310,7 +310,7 @@ This message does not have Content-Type nor Subject.
let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap(); assert_eq!( parser.html, - r##" + r#" @@ -318,7 +318,7 @@ This message does not have Content-Type nor Subject.
message with a non-UTF-8 encoding: äöüßÄÖÜ

-"## +"# ); } @@ -330,7 +330,7 @@ message with a non-UTF-8 encoding: äöüßÄÖÜ
assert!(parser.plain.unwrap().flowed); assert_eq!( parser.html, - r##" + r#" @@ -341,7 +341,7 @@ This line does not end with a space
and will be wrapped as usual.

-"## +"# ); } @@ -352,7 +352,7 @@ and will be wrapped as usual.
let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap(); assert_eq!( parser.html, - r##" + r#" @@ -363,7 +363,7 @@ test some special html-characters as < > and & but also " and &#x

-"## +"# ); } diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 4000b34c4..6131856c2 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -3107,7 +3107,7 @@ CWt6wx7fiLp0qS9RrX75g6Gqw7nfCs6EcBERcIPt7DTe8VStJwf3LWqVwxl4gQl46yhfoqwEO+I= #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn parse_outlook_html_embedded_image() { let context = TestContext::new_alice().await; - let raw = br##"From: Anonymous + let raw = br#"From: Anonymous To: Anonymous Subject: Delta Chat is great stuff! Date: Tue, 5 May 2020 01:23:45 +0000 @@ -3162,7 +3162,7 @@ K+TuvC7qOah0WLFhcsXWn2+dDV1bXuAeC769TkqkpHhdXfUHnVgK3Pv7u3rVPT5AMeFUGxRB2dP4 CWt6wx7fiLp0qS9RrX75g6Gqw7nfCs6EcBERcIPt7DTe8VStJwf3LWqVwxl4gQl46yhfoqwEO+I= ------=_NextPart_000_0003_01D622B3.CA753E60-- -"##; +"#; let message = MimeMessage::from_bytes(&context.ctx, &raw[..], None) .await @@ -3537,7 +3537,7 @@ On 2020-10-25, Bob wrote: // A message with a long Message-ID. // Long message-IDs are generated by Mailjet. - let raw = br###"Date: Thu, 28 Jan 2021 00:26:57 +0000 + let raw = br"Date: Thu, 28 Jan 2021 00:26:57 +0000 Chat-Version: 1.0\n\ Message-ID: To: Bob @@ -3545,11 +3545,11 @@ From: Alice Subject: ... Some quote. -"###; +"; receive_imf(&t, raw, false).await?; // Delta Chat generates In-Reply-To with a starting tab when Message-ID is too long. - let raw = br###"In-Reply-To: + let raw = br"In-Reply-To: Date: Thu, 28 Jan 2021 00:26:57 +0000 Chat-Version: 1.0\n\ @@ -3561,7 +3561,7 @@ Subject: ... > Some quote. Some reply -"###; +"; receive_imf(&t, raw, false).await?; @@ -3579,7 +3579,7 @@ Some reply let alice = TestContext::new_alice().await; let bob = TestContext::new_bob().await; - let raw = br###"Date: Thu, 28 Jan 2021 00:26:57 +0000 + let raw = br"Date: Thu, 28 Jan 2021 00:26:57 +0000 Chat-Version: 1.0\n\ Message-ID: To: Bob @@ -3588,7 +3588,7 @@ Subject: subject Chat-Disposition-Notification-To: alice@example.org Message. -"###; +"; // Bob receives message. receive_imf(&bob, raw, false).await?; diff --git a/src/plaintext.rs b/src/plaintext.rs index afd75b981..0c18fa104 100644 --- a/src/plaintext.rs +++ b/src/plaintext.rs @@ -26,10 +26,10 @@ impl PlainText { /// The function handles quotes, links, fixed and floating text paragraphs. pub fn to_html(&self) -> String { static LINKIFY_MAIL_RE: Lazy = - Lazy::new(|| regex::Regex::new(r#"\b([\w.\-+]+@[\w.\-]+)\b"#).unwrap()); + Lazy::new(|| regex::Regex::new(r"\b([\w.\-+]+@[\w.\-]+)\b").unwrap()); static LINKIFY_URL_RE: Lazy = Lazy::new(|| { - regex::Regex::new(r#"\b((http|https|ftp|ftps):[\w.,:;$/@!?&%\-~=#+]+)"#).unwrap() + regex::Regex::new(r"\b((http|https|ftp|ftps):[\w.,:;$/@!?&%\-~=#+]+)").unwrap() }); let lines = split_lines(&self.text); @@ -127,7 +127,7 @@ http://link-at-start-of-line.org .to_html(); assert_eq!( html, - r##" + r#" @@ -138,7 +138,7 @@ line with https://link-mid-of-line.orghttp://link-at-start-of-line.org

-"## +"# ); } diff --git a/src/provider.rs b/src/provider.rs index 58e1cd517..8035acd88 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -223,7 +223,7 @@ pub async fn get_provider_by_mx(context: &Context, domain: &str) -> Option<&'sta } if let Ok(mx_domains) = resolver.mx_lookup(fqdn).await { - for (provider_domain, provider) in PROVIDER_DATA.iter() { + for (provider_domain, provider) in &*PROVIDER_DATA { if provider.id != "gmail" { // MX lookup is limited to Gmail for security reasons continue; diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 99f1b59be..0dd1dece3 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2345,7 +2345,7 @@ async fn add_or_lookup_contacts_by_address_list( origin: Origin, ) -> Result> { let mut contact_ids = HashSet::new(); - for info in address_list.iter() { + for info in address_list { let addr = &info.addr; if !may_be_valid_addr(addr) { continue; diff --git a/src/smtp.rs b/src/smtp.rs index 284ad1ef9..7ae5a737b 100644 --- a/src/smtp.rs +++ b/src/smtp.rs @@ -55,7 +55,7 @@ impl Smtp { } /// Disconnect the SMTP transport and drop it entirely. - pub async fn disconnect(&mut self) { + pub fn disconnect(&mut self) { if let Some(mut transport) = self.transport.take() { // Closing connection with a QUIT command may take some time, especially if it's a // stale connection and an attempt to send the command times out. Send a command in a @@ -88,7 +88,7 @@ impl Smtp { pub async fn connect_configured(&mut self, context: &Context) -> Result<()> { if self.has_maybe_stale_connection() { info!(context, "Closing stale connection"); - self.disconnect().await; + self.disconnect(); } if self.is_connected() { @@ -465,13 +465,13 @@ pub(crate) async fn smtp_send( // this clears last_success info info!(context, "Failed to send message over SMTP, disconnecting"); - smtp.disconnect().await; + smtp.disconnect(); res } Err(crate::smtp::send::Error::Envelope(err)) => { // Local error, job is invalid, do not retry. - smtp.disconnect().await; + smtp.disconnect(); warn!(context, "SMTP job is invalid: {}", err); SendResult::Failure(err) } @@ -483,7 +483,7 @@ pub(crate) async fn smtp_send( } Err(crate::smtp::send::Error::Other(err)) => { // Local error, job is invalid, do not retry. - smtp.disconnect().await; + smtp.disconnect(); warn!(context, "unable to load job: {}", err); SendResult::Failure(err) }