Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 810f7e1

Browse files
committed
Clippy fixes
1 parent fe23655 commit 810f7e1

15 files changed

+32
-43
lines changed

Cargo.lock

+2-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/install-wheel-rs/src/wheel.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn unpack_wheel_files<R: Read + Seek>(
265265

266266
if let Some(p) = out_path.parent() {
267267
if !created_dirs.contains(p) {
268-
fs::create_dir_all(&p)?;
268+
fs::create_dir_all(p)?;
269269
created_dirs.insert(p.to_path_buf());
270270
}
271271
}
@@ -424,7 +424,7 @@ fn write_script_entrypoints(
424424
record: &mut Vec<RecordEntry>,
425425
) -> Result<(), Error> {
426426
// for monotrail
427-
fs::create_dir_all(site_packages.join(&bin_rel()))?;
427+
fs::create_dir_all(site_packages.join(bin_rel()))?;
428428
for entrypoint in entrypoints {
429429
let entrypoint_relative = if cfg!(windows) {
430430
// On windows we actually build an .exe wrapper
@@ -628,7 +628,7 @@ fn bytecode_compile_inner(
628628
.stdin(Stdio::piped())
629629
.stdout(Stdio::piped())
630630
.stderr(Stdio::inherit())
631-
.current_dir(&site_packages)
631+
.current_dir(site_packages)
632632
.spawn()
633633
.map_err(Error::PythonSubcommand)?;
634634

@@ -708,14 +708,14 @@ fn move_folder_recorded(
708708
record: &mut [RecordEntry],
709709
) -> Result<(), Error> {
710710
if !dest_dir.is_dir() {
711-
fs::create_dir_all(&dest_dir)?;
711+
fs::create_dir_all(dest_dir)?;
712712
}
713-
for entry in WalkDir::new(&src_dir) {
713+
for entry in WalkDir::new(src_dir) {
714714
let entry = entry?;
715715
let src = entry.path();
716716
// This is the base path for moving to the actual target for the data
717717
// e.g. for data it's without <..>.data/data/
718-
let relative_to_data = src.strip_prefix(&src_dir).expect("Prefix must no change");
718+
let relative_to_data = src.strip_prefix(src_dir).expect("Prefix must no change");
719719
// This is the path stored in RECORD
720720
// e.g. for data it's with .data/data/
721721
let relative_to_site_packages = src
@@ -787,7 +787,7 @@ fn install_script(
787787
} else {
788788
// reading and writing is slow especially for large binaries, so we move them instead
789789
drop(script);
790-
fs::rename(&path, &site_packages.join(&target_path))?;
790+
fs::rename(&path, site_packages.join(&target_path))?;
791791
None
792792
};
793793
#[cfg(unix)]
@@ -1377,7 +1377,7 @@ mod test {
13771377
.join("site-packages")
13781378
.join("colander-0.9.9.dist-info")
13791379
.join("RECORD");
1380-
let record = fs::read_to_string(&record).unwrap();
1380+
let record = fs::read_to_string(record).unwrap();
13811381
for line in record.lines() {
13821382
assert!(!line.starts_with('/'), "{}", line);
13831383
}

crates/monotrail-utils/src/parse_cpython_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn naive_python_arg_parser<T: AsRef<str>>(args: &[T]) -> Result<Option<Strin
7171
pub fn parse_plus_arg(
7272
python_args: &[String],
7373
) -> Result<(Vec<String>, Option<(u8, u8)>), ParsePythonVersionError> {
74-
if let Some(first_arg) = python_args.get(0) {
74+
if let Some(first_arg) = python_args.first() {
7575
if first_arg.starts_with('+') {
7676
let python_version = parse_major_minor(first_arg)?;
7777
return Ok((python_args[1..].to_vec(), Some(python_version)));

crates/monotrail-utils/src/standalone_python.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mod test {
297297
use crate::standalone_python::{find_python, PYTHON_STANDALONE_LATEST_RELEASE};
298298
use mockito::{Mock, ServerGuard};
299299
use std::path::PathBuf;
300-
use tempfile::tempdir;
300+
301301

302302
pub fn zstd_json_mock(url: &str, fixture: impl Into<PathBuf>) -> (ServerGuard, Mock) {
303303
use fs_err::File;

crates/monotrail/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ libloading = "0.8.0"
2424
libz-sys = { version = "1.1.12", features = ["static"] } # For the zig build
2525
monotrail-utils = { version = "0.0.1", path = "../monotrail-utils" }
2626
nix = { version = "0.27.1", features = ["process"] }
27-
pep440_rs = "0.3.11"
27+
pep440_rs = "0.4.0"
2828
pep508_rs = { workspace = true, features = ["serde"] }
2929
pyo3 = { workspace = true, features = ["extension-module", "abi3-py37"], optional = true }
3030
rayon = "1.8.0"

crates/monotrail/src/cli.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub fn download_distribution_cached(
188188
url: &str,
189189
) -> anyhow::Result<PathBuf> {
190190
let target_dir = cache_dir()?.join("artifacts").join(name).join(version);
191-
let target_file = target_dir.join(&filename);
191+
let target_file = target_dir.join(filename);
192192

193193
if target_file.is_file() {
194194
debug!(
@@ -433,7 +433,7 @@ pub fn run_cli(cli: Cli, venv: Option<&Path>) -> anyhow::Result<Option<i32>> {
433433
// extended to run this in parallel.
434434
// Would be nicer to use a fork wrapper here
435435
let status = Command::new(env::current_exe()?)
436-
.args(&["run", "-p", &version, "python"])
436+
.args(["run", "-p", &version, "python"])
437437
.args(&trail_args)
438438
.status()
439439
.context("Failed to start child process for python version")?;

crates/monotrail/src/inject_and_run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ pub fn inject_and_run_python(
258258
// is an even bigger mess
259259
let args_cstring: Vec<WideCString> = args
260260
.iter()
261-
.map(|arg| WideCString::from_str(&arg).unwrap())
261+
.map(|arg| WideCString::from_str(arg).unwrap())
262262
.collect();
263263
let mut args_c_char: Vec<*const wchar_t> = args_cstring
264264
.iter()

crates/monotrail/src/install.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ pub fn repo_at_revision(url: &str, revision: &str, repo_dir: &Path) -> anyhow::R
292292
Ok(repo) => Some(repo),
293293
Err(err) => {
294294
warn!("Repository directory {} exists, but can't be opened as a git repository, recreating: {}", repo_dir.display(), err);
295-
fs::remove_dir_all(&repo_dir).context("Failed to remove old repo dir")?;
295+
fs::remove_dir_all(repo_dir).context("Failed to remove old repo dir")?;
296296
None
297297
}
298298
}
@@ -323,7 +323,7 @@ pub fn repo_at_revision(url: &str, revision: &str, repo_dir: &Path) -> anyhow::R
323323
// https://stackoverflow.com/q/3489173/3549270
324324
let mut tries = 1;
325325
loop {
326-
let result = Repository::clone(url, &repo_dir);
326+
let result = Repository::clone(url, repo_dir);
327327
let backoff = Duration::from_secs(1);
328328
tries -= 1;
329329
match result {
@@ -336,7 +336,7 @@ pub fn repo_at_revision(url: &str, revision: &str, repo_dir: &Path) -> anyhow::R
336336
backoff.as_secs()
337337
);
338338
if repo_dir.is_dir() {
339-
fs::remove_dir_all(&repo_dir)
339+
fs::remove_dir_all(repo_dir)
340340
.context("Failed to remove broken repo dir")?;
341341
}
342342
sleep(backoff);
@@ -446,7 +446,7 @@ fn download_and_install(
446446
true,
447447
&spec.extras,
448448
&spec.unique_version,
449-
&sys_executable,
449+
sys_executable,
450450
)
451451
.with_context(|| format!("Failed to install {}", spec.requested))?;
452452
Ok((spec.python_version, spec.unique_version, tag))

crates/monotrail/src/monotrail.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ pub fn find_scripts(
655655

656656
pub fn is_python_script(executable: &Path) -> anyhow::Result<bool> {
657657
// Check whether we're launching a monotrail python script
658-
let mut executable_file = File::open(&executable)
658+
let mut executable_file = File::open(executable)
659659
.context("the executable file was right there and is now unreadable ಠ_ಠ")?;
660660
// scripts might be binaries, so we read an exact number of bytes instead of the first line as string
661661
let mut start = vec![0; SHEBANG_PYTHON.as_bytes().len()];

crates/monotrail/src/package_index.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ pub(crate) fn download_distribution(
134134
target_file: &Path,
135135
) -> Result<()> {
136136
debug!("Downloading wheel to {}", target_file.display());
137-
fs::create_dir_all(&target_dir).context("Couldn't create cache dir")?;
137+
fs::create_dir_all(target_dir).context("Couldn't create cache dir")?;
138138
// temp file so we don't clash with other processes running in parallel
139-
let mut temp_file = tempfile::NamedTempFile::new_in(&target_dir)
139+
let mut temp_file = tempfile::NamedTempFile::new_in(target_dir)
140140
.context("Couldn't create file for download")?;
141141
let request_for_file = ureq::get(url)
142142
.set("User-Agent", "monotrail ([email protected])")
@@ -145,7 +145,7 @@ pub(crate) fn download_distribution(
145145
io::copy(&mut request_for_file.into_reader(), &mut temp_file)
146146
.context("Failed to download wheel from pypi")?;
147147
temp_file
148-
.persist(&target_file)
148+
.persist(target_file)
149149
.context("Failed to moved wheel to target position")?;
150150
Ok(())
151151
}

crates/monotrail/src/poetry_integration/lock.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn poetry_resolve(
7373
// and minimize the resolution work
7474
let poetry_lock_path = resolve_dir.path().join("poetry.lock");
7575
if let Some(lockfile) = lockfile {
76-
fs::write(&poetry_lock_path, &lockfile)?;
76+
fs::write(&poetry_lock_path, lockfile)?;
7777
}
7878

7979
poetry_resolve_from_dir(&resolve_dir, &python_context)?;
@@ -149,7 +149,7 @@ pub fn poetry_resolve_from_dir(
149149
let result = Command::new(&current_exe)
150150
.args(&args)
151151
// This will make poetry-resolve find the pyproject.toml we want to resolve
152-
.current_dir(&resolve_dir)
152+
.current_dir(resolve_dir)
153153
.status();
154154
(result, current_exe, args)
155155
}
@@ -170,7 +170,7 @@ pub fn poetry_resolve_from_dir(
170170
&poetry_boostrap_lock,
171171
)
172172
// This will make poetry lock the right deps
173-
.current_dir(&resolve_dir)
173+
.current_dir(resolve_dir)
174174
.status();
175175
(result, python_context.sys_executable.clone(), args)
176176
}

crates/monotrail/src/ppipx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn generate_ppipx_entry(
132132
build_system: None,
133133
};
134134

135-
fs::create_dir_all(&resolution_dir).context("Failed to create ppipx resolution dir")?;
135+
fs::create_dir_all(resolution_dir).context("Failed to create ppipx resolution dir")?;
136136
let resolve_dir = TempDir::new()?;
137137
fs::write(
138138
resolve_dir.path().join("pyproject.toml"),

crates/monotrail/src/python_bindings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn monotrail_from_args(py: Python, args: Vec<String>) -> PyResult<InjectData
9494
// step
9595
let script = naive_python_arg_parser(&args).map_err(PyRuntimeError::new_err)?;
9696
let script = if let Some(script) =
97-
env::var_os(&format!("{}_CWD", env!("CARGO_PKG_NAME").to_uppercase()))
97+
env::var_os(format!("{}_CWD", env!("CARGO_PKG_NAME").to_uppercase()))
9898
{
9999
Some(PathBuf::from(script))
100100
} else {

crates/monotrail/src/source_distribution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn build_to_wheel(
5252
) -> Result<PathBuf> {
5353
let output = Command::new("pip")
5454
.current_dir(build_dir)
55-
.args(&["wheel", "--no-deps"])
55+
.args(["wheel", "--no-deps"])
5656
.arg(sdist_or_dir)
5757
.output()
5858
.context("Failed to invoke pip")?;

crates/monotrail/src/verify_installation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn verify_package(
2424
tag: &str,
2525
) -> anyhow::Result<Vec<String>> {
2626
let mut failing = Vec::new();
27-
let package_root = root.join(&name).join(&unique_version).join(&tag);
27+
let package_root = root.join(name).join(unique_version).join(tag);
2828
let site_packages = if cfg!(windows) {
2929
package_root.join("Lib").join("site-packages")
3030
} else {
@@ -46,7 +46,7 @@ fn verify_package(
4646
// normalize package name
4747
.to_lowercase()
4848
.replace('-', "_")
49-
.starts_with(&name)
49+
.starts_with(name)
5050
&& dir.file_name().to_string_lossy().ends_with(".dist-info")
5151
})
5252
.map(|entry| entry.path())

0 commit comments

Comments
 (0)