From edc73bc18e625c12d66a8bce98a80eeae57aa105 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:07:40 +0000 Subject: [PATCH 1/4] Update Rust crate ureq to v3 --- Cargo.lock | 74 ++++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b34e20e788c2..116a95c0aa1af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -255,6 +255,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" + [[package]] name = "cachedir" version = "0.3.1" @@ -478,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -487,7 +493,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -904,7 +910,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1138,6 +1144,23 @@ dependencies = [ "utf8-width", ] +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + [[package]] name = "humantime" version = "2.1.0" @@ -1459,7 +1482,7 @@ checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" dependencies = [ "hermit-abi 0.4.0", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3250,7 +3273,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3268,6 +3291,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "rustls-pki-types" version = "1.10.1" @@ -3672,7 +3704,7 @@ dependencies = [ "getrandom", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4124,20 +4156,36 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.12.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d" +checksum = "7b35e5241ee2cad3940e69c78b28b3600bec9c57146bce26b3eb888869b987d4" dependencies = [ "base64 0.22.1", + "cc", "flate2", "log", "once_cell", + "percent-encoding", "rustls", + "rustls-pemfile", "rustls-pki-types", - "url", + "ureq-proto", + "utf-8", "webpki-roots", ] +[[package]] +name = "ureq-proto" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42506c1d9fc65bcf2508cb8f9b5e7d21f88e71567fbb7595ca5e5bd5218ca7db" +dependencies = [ + "base64 0.22.1", + "http", + "httparse", + "log", +] + [[package]] name = "url" version = "2.5.4" @@ -4156,6 +4204,12 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf16_iter" version = "1.0.5" @@ -4458,7 +4512,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c74e1b8bbc2cb..e4d24372930c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,7 +159,7 @@ unicode-ident = { version = "1.0.12" } unicode-width = { version = "0.2.0" } unicode_names2 = { version = "1.2.2" } unicode-normalization = { version = "0.1.23" } -ureq = { version = "2.9.6" } +ureq = { version = "3.0.0" } url = { version = "2.5.0" } uuid = { version = "1.6.1", features = [ "v4", From a898044c6f5baa03e52c591b417ca4f827a6dd91 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Mon, 27 Jan 2025 21:21:23 +0530 Subject: [PATCH 2/4] Update for the latest API --- crates/ruff_benchmark/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ruff_benchmark/src/lib.rs b/crates/ruff_benchmark/src/lib.rs index cb6236c29a1e5..d720a100fcdfd 100644 --- a/crates/ruff_benchmark/src/lib.rs +++ b/crates/ruff_benchmark/src/lib.rs @@ -119,9 +119,9 @@ impl TestFile { Ok(TestFile::new(name.to_string(), content)) } else { // File not yet cached, download and cache it in the target directory - let response = ureq::get(url.as_str()).call()?; + let mut response = ureq::get(url.as_str()).call()?; - let content = response.into_string()?; + let content = String::from_utf8_lossy(&response.body_mut().read_to_vec()?).to_string(); // SAFETY: There's always the `target` directory let parent = cached_filename.parent().unwrap(); From bfd76561cef19a31ea74927af604c3155c971e8e Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 29 Jan 2025 10:21:27 +0530 Subject: [PATCH 3/4] Upgrade to 3.0.2 --- Cargo.lock | 9 ++++----- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 116a95c0aa1af..213dc6fbf0d32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4156,15 +4156,14 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b35e5241ee2cad3940e69c78b28b3600bec9c57146bce26b3eb888869b987d4" +checksum = "aa6a209bb4b8d5903579fc4f8cd12ce5594f1ed6b735bf290ab5e2bdb3e70013" dependencies = [ "base64 0.22.1", "cc", "flate2", "log", - "once_cell", "percent-encoding", "rustls", "rustls-pemfile", @@ -4176,9 +4175,9 @@ dependencies = [ [[package]] name = "ureq-proto" -version = "0.2.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42506c1d9fc65bcf2508cb8f9b5e7d21f88e71567fbb7595ca5e5bd5218ca7db" +checksum = "2c51fe73e1d8c4e06bb2698286f7e7453c6fc90528d6d2e7fc36bb4e87fe09b1" dependencies = [ "base64 0.22.1", "http", diff --git a/Cargo.toml b/Cargo.toml index e4d24372930c9..c0c2a13708462 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,7 +159,7 @@ unicode-ident = { version = "1.0.12" } unicode-width = { version = "0.2.0" } unicode_names2 = { version = "1.2.2" } unicode-normalization = { version = "0.1.23" } -ureq = { version = "3.0.0" } +ureq = { version = "3.0.2" } url = { version = "2.5.0" } uuid = { version = "1.6.1", features = [ "v4", From b73e710a98767e4bdab6ef03f6ffa2b71e772f02 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Sun, 2 Feb 2025 12:41:22 +0100 Subject: [PATCH 4/4] Use `read_to_string` --- Cargo.lock | 4 ++-- Cargo.toml | 15 ++++++++++++--- crates/ruff_benchmark/benches/lexer.rs | 5 +++++ crates/ruff_benchmark/src/lib.rs | 12 +++++++++--- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 213dc6fbf0d32..5065043807b26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4156,9 +4156,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa6a209bb4b8d5903579fc4f8cd12ce5594f1ed6b735bf290ab5e2bdb3e70013" +checksum = "217751151c53226090391713e533d9a5e904ba2570dabaaace29032687589c3e" dependencies = [ "base64 0.22.1", "cc", diff --git a/Cargo.toml b/Cargo.toml index c0c2a13708462..ca85c66599514 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,7 +134,12 @@ serde_with = { version = "3.6.0", default-features = false, features = [ shellexpand = { version = "3.0.0" } similar = { version = "2.4.0", features = ["inline"] } smallvec = { version = "1.13.2" } -snapbox = { version = "0.6.0", features = ["diff", "term-svg", "cmd", "examples"] } +snapbox = { version = "0.6.0", features = [ + "diff", + "term-svg", + "cmd", + "examples", +] } static_assertions = "1.1.0" strum = { version = "0.26.0", features = ["strum_macros"] } strum_macros = { version = "0.26.0" } @@ -159,7 +164,7 @@ unicode-ident = { version = "1.0.12" } unicode-width = { version = "0.2.0" } unicode_names2 = { version = "1.2.2" } unicode-normalization = { version = "0.1.23" } -ureq = { version = "3.0.2" } +ureq = { version = "3.0.3" } url = { version = "2.5.0" } uuid = { version = "1.6.1", features = [ "v4", @@ -305,7 +310,11 @@ local-artifacts-jobs = ["./build-binaries", "./build-docker"] # Publish jobs to run in CI publish-jobs = ["./publish-pypi", "./publish-wasm"] # Post-announce jobs to run in CI -post-announce-jobs = ["./notify-dependents", "./publish-docs", "./publish-playground"] +post-announce-jobs = [ + "./notify-dependents", + "./publish-docs", + "./publish-playground", +] # Custom permissions for GitHub Jobs github-custom-job-permissions = { "build-docker" = { packages = "write", contents = "read" }, "publish-wasm" = { contents = "read", id-token = "write", packages = "write" } } # Whether to install an updater program diff --git a/crates/ruff_benchmark/benches/lexer.rs b/crates/ruff_benchmark/benches/lexer.rs index 64b68a7a3539a..50539ba9b52c6 100644 --- a/crates/ruff_benchmark/benches/lexer.rs +++ b/crates/ruff_benchmark/benches/lexer.rs @@ -56,6 +56,11 @@ fn benchmark_lexer(criterion: &mut Criterion) { _ => {} } } + + assert!( + lexer.finish().is_empty(), + "Input to be valid python source code" + ); }); }, ); diff --git a/crates/ruff_benchmark/src/lib.rs b/crates/ruff_benchmark/src/lib.rs index d720a100fcdfd..50744a613d204 100644 --- a/crates/ruff_benchmark/src/lib.rs +++ b/crates/ruff_benchmark/src/lib.rs @@ -119,9 +119,15 @@ impl TestFile { Ok(TestFile::new(name.to_string(), content)) } else { // File not yet cached, download and cache it in the target directory - let mut response = ureq::get(url.as_str()).call()?; - - let content = String::from_utf8_lossy(&response.body_mut().read_to_vec()?).to_string(); + let response = ureq::get(url.as_str()).call()?; + + // Using `with_config` here because without, the `loosy_utf8` results in invalid + // UTF8 for unknown reasons + let content = response + .into_body() + .with_config() + .limit(10 * 1024 * 1024) + .read_to_string()?; // SAFETY: There's always the `target` directory let parent = cached_filename.parent().unwrap();