Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy lints and update pep440_rs and pep508_rs #882

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix clippy lints
cnpryer committed Feb 3, 2024
commit c97fe31a2962bc15b99bcedd6747a5a2560dd66c
4 changes: 1 addition & 3 deletions crates/huak-package-manager/src/ops/toolchain.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
/// already installed to the toolchain, and a version is provided that's different from the
/// installed tool, then replace the installed tool with the desired version.
pub fn add_tool(tool: &LocalTool, channel: Option<&Channel>, config: &Config) -> HuakResult<()> {
// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.

Check warning on line 26 in crates/huak-package-manager/src/ops/toolchain.rs

GitHub Actions / Spell check

"curerent" should be "current".
let toolchain = config.workspace().resolve_local_toolchain(channel)?;

add_tool_to_toolchain(tool, &toolchain, config)
@@ -360,7 +360,7 @@
unimplemented!()
}

// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.

Check warning on line 363 in crates/huak-package-manager/src/ops/toolchain.rs

GitHub Actions / Spell check

"curerent" should be "current".
let toolchain = config.workspace().resolve_local_toolchain(channel)?;
let venv = PythonEnvironment::new(toolchain.root().join(".venv"))?;

@@ -492,7 +492,7 @@
channel: Option<&Channel>,
config: &Config,
) -> HuakResult<()> {
// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.

Check warning on line 495 in crates/huak-package-manager/src/ops/toolchain.rs

GitHub Actions / Spell check

"curerent" should be "current".
let toolchain = config.workspace().resolve_local_toolchain(channel)?;

let mut terminal = config.terminal();
@@ -551,9 +551,7 @@
}

fn resolve_installed_toolchains(config: &Config) -> Option<Vec<LocalToolchain>> {
let Some(home) = config.home.clone() else {
return None;
};
let home = config.home.clone()?;

let Ok(toolchains) = std::fs::read_dir(home.join("toolchains")) else {
return None;
2 changes: 1 addition & 1 deletion crates/huak-package-manager/src/python_environment.rs
Original file line number Diff line number Diff line change
@@ -655,7 +655,7 @@ mod tests {
fn python_search() {
let dir = tempdir().unwrap();
std::fs::write(dir.path().join("python3.11"), "").unwrap();
let path_vals = vec![dir.path().to_str().unwrap().to_string()];
let path_vals = [dir.path().to_str().unwrap().to_string()];
std::env::set_var("PATH", path_vals.join(":"));
let mut interpreter_paths = python_paths();

6 changes: 1 addition & 5 deletions crates/huak-package-manager/src/workspace.rs
Original file line number Diff line number Diff line change
@@ -199,11 +199,7 @@ fn resolve_local_toolchain(
channel: Option<&Channel>,
) -> Option<LocalToolchain> {
let config = &workspace.config;

let Some(home) = config.home.as_ref() else {
return None;
};

let home = config.home.as_ref()?;
let toolchains = home.join("toolchains");
let settings = toolchains.join("settings.toml");

14 changes: 4 additions & 10 deletions crates/huak-pyproject-toml/src/lib.rs
Original file line number Diff line number Diff line change
@@ -184,13 +184,10 @@ impl PyProjectToml {

#[must_use]
pub fn project_dependencies(&self) -> Option<Vec<String>> {
let Some(array) = self
let array = self
.project_table()
.and_then(|it| it.get("dependencies"))
.and_then(Item::as_array)
else {
return None;
};
.and_then(Item::as_array)?;

Some(
array
@@ -245,13 +242,10 @@ impl PyProjectToml {

#[must_use]
pub fn project_optional_dependencies(&self) -> Option<HashMap<String, Vec<String>>> {
let Some(table) = self
let table = self
.project_table()
.and_then(|it| it.get("optional-dependencies"))
.and_then(Item::as_table)
else {
return None;
};
.and_then(Item::as_table)?;

let mut deps = HashMap::new();
let groups = table.iter().map(|(k, _)| k).collect::<Vec<_>>();
28 changes: 14 additions & 14 deletions crates/huak-python-manager/src/install.rs
Original file line number Diff line number Diff line change
@@ -168,24 +168,24 @@ mod tests {
let py = bin.join("python");
let py3 = bin.join("python3");
let py312 = bin.join("python3.12");
let pys = [py.clone(), py3, py312];
let pythons = [py.clone(), py3, py312];
let module = bin.join("module");

std::fs::create_dir_all(&bin).unwrap();

for file in pys.iter().chain([&module]) {
for file in pythons.iter().chain([&module]) {
let mut file = File::create(file).unwrap();
file.write_all(&[]).unwrap();
}

let release_dir = PythonReleaseDir::new(dir);

let ibin = release_dir.bin_path();
let ipy = ibin.join("python");
let release_bin = release_dir.bin_path();
let release_py = release_bin.join("python");

assert_eq!(bin, ibin);
assert_eq!(py, ipy);
assert_eq!(module, ibin.join("module"));
assert_eq!(bin, release_bin);
assert_eq!(py, release_py);
assert_eq!(module, release_bin.join("module"));
}

#[cfg(windows)]
@@ -197,23 +197,23 @@ mod tests {
let parent = dir.join("install");
let bin = parent.join("Scripts");
let py = parent.join("python.exe");
let pys = [py.clone()];
let pythons = [py.clone()];
let module = bin.join("module.exe");

std::fs::create_dir_all(&bin).unwrap();

for file in pys.iter().chain([&module]) {
for file in pythons.iter().chain([&module]) {
let mut file = File::create(file).unwrap();
file.write_all(&[]).unwrap();
}

let release_dir = PythonReleaseDir::new(dir);

let ibin = release_dir.bin_path();
let ipy = release_dir.python_path(None);
let release_bin = release_dir.bin_path();
let release_py = release_dir.python_path(None);

assert_eq!(bin, ibin);
assert_eq!(py, ipy);
assert_eq!(module, ibin.join("module.exe"));
assert_eq!(bin, release_bin);
assert_eq!(py, release_py);
assert_eq!(module, release_bin.join("module.exe"));
}
}