Skip to content

Commit da76b77

Browse files
Copilotkarthiknadig
andcommitted
Fix code formatting for venv-uv implementation
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
1 parent 66d9591 commit da76b77

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

crates/pet-core/src/pyvenv_cfg.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ fn parse(file: &Path) -> Option<PyVenvCfg> {
138138
}
139139

140140
match (version, version_major, version_minor) {
141-
(Some(ver), Some(major), Some(minor)) => Some(PyVenvCfg::new(ver, major, minor, prompt, uv_version)),
141+
(Some(ver), Some(major), Some(minor)) => {
142+
Some(PyVenvCfg::new(ver, major, minor, prompt, uv_version))
143+
}
142144
_ => None,
143145
}
144146
}
@@ -219,14 +221,20 @@ fn parse_uv_version(line: &str) -> Option<String> {
219221
#[cfg(test)]
220222
mod tests {
221223
use super::*;
222-
use std::{path::PathBuf, fs};
224+
use std::{fs, path::PathBuf};
223225

224226
#[test]
225227
fn test_parse_uv_version() {
226228
assert_eq!(parse_uv_version("uv = 0.8.14"), Some("0.8.14".to_string()));
227229
assert_eq!(parse_uv_version("uv=0.8.14"), Some("0.8.14".to_string()));
228-
assert_eq!(parse_uv_version("uv = \"0.8.14\""), Some("0.8.14".to_string()));
229-
assert_eq!(parse_uv_version("uv = '0.8.14'"), Some("0.8.14".to_string()));
230+
assert_eq!(
231+
parse_uv_version("uv = \"0.8.14\""),
232+
Some("0.8.14".to_string())
233+
);
234+
assert_eq!(
235+
parse_uv_version("uv = '0.8.14'"),
236+
Some("0.8.14".to_string())
237+
);
230238
assert_eq!(parse_uv_version("version = 3.12.11"), None);
231239
assert_eq!(parse_uv_version("prompt = test-env"), None);
232240
}
@@ -236,12 +244,12 @@ mod tests {
236244
let temp_file = "/tmp/test_pyvenv_uv.cfg";
237245
let contents = "home = /usr/bin/python3.12\nimplementation = CPython\nuv = 0.8.14\nversion_info = 3.12.11\ninclude-system-site-packages = false\nprompt = test-uv-env\n";
238246
fs::write(temp_file, contents).unwrap();
239-
247+
240248
let cfg = parse(&PathBuf::from(temp_file)).unwrap();
241249
assert!(cfg.is_uv());
242250
assert_eq!(cfg.uv_version, Some("0.8.14".to_string()));
243251
assert_eq!(cfg.prompt, Some("test-uv-env".to_string()));
244-
252+
245253
fs::remove_file(temp_file).ok();
246254
}
247255

@@ -250,11 +258,11 @@ mod tests {
250258
let temp_file = "/tmp/test_pyvenv_regular.cfg";
251259
let contents = "home = /usr/bin/python3.12\ninclude-system-site-packages = false\nversion = 3.13.5\nexecutable = /usr/bin/python3.12\ncommand = python -m venv /path/to/env\n";
252260
fs::write(temp_file, contents).unwrap();
253-
261+
254262
let cfg = parse(&PathBuf::from(temp_file)).unwrap();
255263
assert!(!cfg.is_uv());
256264
assert_eq!(cfg.uv_version, None);
257-
265+
258266
fs::remove_file(temp_file).ok();
259267
}
260268
}

crates/pet-venv-uv/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,19 @@ mod tests {
118118
fn test_is_venv_uv_dir_does_not_detect_regular_environment() {
119119
// This test checks if we can properly ignore regular venv environments
120120
let regular_env_path = PathBuf::from("/tmp/test_regular_env");
121-
assert!(!is_venv_uv_dir(&regular_env_path), "Should not detect regular venv as UV environment");
121+
assert!(
122+
!is_venv_uv_dir(&regular_env_path),
123+
"Should not detect regular venv as UV environment"
124+
);
122125
}
123126

124127
#[test]
125128
fn test_is_venv_uv_dir_handles_nonexistent_environment() {
126129
// This test checks if we handle non-existent environments gracefully
127130
let nonexistent_path = PathBuf::from("/tmp/nonexistent_env");
128-
assert!(!is_venv_uv_dir(&nonexistent_path), "Should not detect non-existent environment as UV");
131+
assert!(
132+
!is_venv_uv_dir(&nonexistent_path),
133+
"Should not detect non-existent environment as UV"
134+
);
129135
}
130-
}
136+
}

0 commit comments

Comments
 (0)