Skip to content

Commit

Permalink
Fix clippy lints and update pep440_rs and pep508_rs (#882)
Browse files Browse the repository at this point in the history
* Fix clippy lints

* Typos

* Update pep440_rs and pep508_rs
  • Loading branch information
cnpryer authored Feb 3, 2024
1 parent 4cb2100 commit ba2b1e3
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 55 deletions.
46 changes: 29 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ glob = "0.3.1"
hex = "0.4.3"
human-panic = "1.1.5"
lazy_static = "1.4.0"
pep440_rs = "0.3.11"
pep508_rs = "0.2.1"
pep440_rs = "0.4.0"
pep508_rs = "0.2.4"
regex = "1.10.2"
sha2 = "0.10.8"
tempfile = "3.7.1"
Expand Down
10 changes: 4 additions & 6 deletions crates/huak-package-manager/src/ops/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use termcolor::Color;
/// 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.
// Resolve a toolchain if a channel is provided. Otherwise resolve the current.
let toolchain = config.workspace().resolve_local_toolchain(channel)?;

add_tool_to_toolchain(tool, &toolchain, config)
Expand Down Expand Up @@ -360,7 +360,7 @@ pub fn remove_tool(tool: &LocalTool, channel: Option<&Channel>, config: &Config)
unimplemented!()
}

// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.
// Resolve a toolchain if a channel is provided. Otherwise resolve the current.
let toolchain = config.workspace().resolve_local_toolchain(channel)?;
let venv = PythonEnvironment::new(toolchain.root().join(".venv"))?;

Expand Down Expand Up @@ -492,7 +492,7 @@ pub fn update_toolchain(
channel: Option<&Channel>,
config: &Config,
) -> HuakResult<()> {
// Resolve a toolchain if a channel is provided. Otherwise resolve the curerent.
// Resolve a toolchain if a channel is provided. Otherwise resolve the current.
let toolchain = config.workspace().resolve_local_toolchain(channel)?;

let mut terminal = config.terminal();
Expand Down Expand Up @@ -551,9 +551,7 @@ pub fn use_toolchain(channel: &Channel, config: &Config) -> HuakResult<()> {
}

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;
Expand Down
2 changes: 1 addition & 1 deletion crates/huak-package-manager/src/python_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 1 addition & 5 deletions crates/huak-package-manager/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
14 changes: 4 additions & 10 deletions crates/huak-pyproject-toml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<_>>();
Expand Down
28 changes: 14 additions & 14 deletions crates/huak-python-manager/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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"));
}
}

0 comments on commit ba2b1e3

Please sign in to comment.