Skip to content

Commit 0982c56

Browse files
Copilotkarthiknadig
andcommitted
Apply cargo fmt formatting across the workspace
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
1 parent 5770a5a commit 0982c56

File tree

7 files changed

+104
-106
lines changed

7 files changed

+104
-106
lines changed

crates/pet-conda/tests/ci_test.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ fn detect_new_conda_env() {
132132
let env = environments
133133
.iter()
134134
.find(|x| x.name == Some(env_name.into()))
135-
.unwrap_or_else(|| panic!("New Environment not created, detected envs {:?}",
136-
environments));
135+
.unwrap_or_else(|| {
136+
panic!(
137+
"New Environment not created, detected envs {:?}",
138+
environments
139+
)
140+
});
137141

138142
let prefix = conda_dir.clone().join("envs").join(env_name);
139143
assert_eq!(env.prefix, prefix.clone().into());
@@ -226,8 +230,12 @@ fn detect_new_conda_env_without_python() {
226230
let env = environments
227231
.iter()
228232
.find(|x| x.name == Some(env_name.into()))
229-
.unwrap_or_else(|| panic!("New Environment not created, detected envs {:?}",
230-
environments));
233+
.unwrap_or_else(|| {
234+
panic!(
235+
"New Environment not created, detected envs {:?}",
236+
environments
237+
)
238+
});
231239

232240
let prefix = conda_dir.clone().join("envs").join(env_name);
233241
assert_eq!(env.prefix, prefix.clone().into());
@@ -271,8 +279,12 @@ fn detect_new_conda_env_created_with_p_flag_without_python() {
271279
let env = environments
272280
.iter()
273281
.find(|x| x.prefix == Some(prefix.clone()))
274-
.unwrap_or_else(|| panic!("New Environment ({:?}) not created, detected envs {:?}",
275-
prefix, environments));
282+
.unwrap_or_else(|| {
283+
panic!(
284+
"New Environment ({:?}) not created, detected envs {:?}",
285+
prefix, environments
286+
)
287+
});
276288

277289
assert_eq!(env.prefix, prefix.clone().into());
278290
assert_eq!(env.name, None);
@@ -319,8 +331,12 @@ fn detect_new_conda_env_created_with_p_flag_with_python() {
319331
let env = environments
320332
.iter()
321333
.find(|x| x.prefix == Some(prefix.clone()))
322-
.unwrap_or_else(|| panic!("New Environment not created, detected envs {:?}",
323-
environments));
334+
.unwrap_or_else(|| {
335+
panic!(
336+
"New Environment not created, detected envs {:?}",
337+
environments
338+
)
339+
});
324340

325341
assert_eq!(env.prefix, prefix.clone().into());
326342
assert_eq!(env.name, None);

crates/pet-conda/tests/utils_test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ fn is_not_conda_install() {
2323
assert!(!utils::is_conda_install(&path));
2424

2525
// Conda env is not an install location.
26-
let path: PathBuf =
27-
resolve_test_path(&["unix", "anaconda3-2023.03", "envs", "env_python_3"]);
26+
let path: PathBuf = resolve_test_path(&["unix", "anaconda3-2023.03", "envs", "env_python_3"]);
2827
assert!(!utils::is_conda_install(&path));
2928
}
3029

@@ -37,8 +36,7 @@ fn is_conda_env() {
3736
let path: PathBuf = resolve_test_path(&["unix", "anaconda3-2023.03-without-history"]);
3837
assert!(utils::is_conda_env(&path));
3938

40-
let path: PathBuf =
41-
resolve_test_path(&["unix", "anaconda3-2023.03", "envs", "env_python_3"]);
39+
let path: PathBuf = resolve_test_path(&["unix", "anaconda3-2023.03", "envs", "env_python_3"]);
4240
assert!(utils::is_conda_env(&path));
4341
}
4442

crates/pet-poetry/src/config.rs

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -241,56 +241,46 @@ create = false
241241
242242
"#;
243243

244-
assert!(
245-
!parse_contents(cfg)
246-
.unwrap()
247-
.virtualenvs_in_project
248-
.unwrap_or_default()
249-
);
244+
assert!(!parse_contents(cfg)
245+
.unwrap()
246+
.virtualenvs_in_project
247+
.unwrap_or_default());
250248

251249
let cfg = r#"
252250
[virtualenvs]
253251
in-project = true
254252
create = false
255253
256254
"#;
257-
assert!(
258-
parse_contents(cfg)
259-
.unwrap()
260-
.virtualenvs_in_project
261-
.unwrap_or_default()
262-
);
255+
assert!(parse_contents(cfg)
256+
.unwrap()
257+
.virtualenvs_in_project
258+
.unwrap_or_default());
263259

264260
let cfg = r#"
265261
[virtualenvs]
266262
create = false
267263
268264
"#;
269-
assert!(
270-
!parse_contents(cfg)
271-
.unwrap()
272-
.virtualenvs_in_project
273-
.unwrap_or_default()
274-
);
265+
assert!(!parse_contents(cfg)
266+
.unwrap()
267+
.virtualenvs_in_project
268+
.unwrap_or_default());
275269

276270
let cfg = r#"
277271
virtualenvs.in-project = true # comment
278272
"#;
279-
assert!(
280-
parse_contents(cfg)
281-
.unwrap()
282-
.virtualenvs_in_project
283-
.unwrap_or_default()
284-
);
273+
assert!(parse_contents(cfg)
274+
.unwrap()
275+
.virtualenvs_in_project
276+
.unwrap_or_default());
285277

286278
let cfg = r#"
287279
"#;
288-
assert!(
289-
!parse_contents(cfg)
290-
.unwrap()
291-
.virtualenvs_in_project
292-
.unwrap_or_default()
293-
);
280+
assert!(!parse_contents(cfg)
281+
.unwrap()
282+
.virtualenvs_in_project
283+
.unwrap_or_default());
294284
}
295285

296286
#[test]
@@ -326,10 +316,7 @@ virtualenvs.path = "/path/to/virtualenvs"
326316
some-other-value = 1234
327317
328318
"#;
329-
assert_eq!(
330-
parse_contents(cfg).unwrap().virtualenvs_path,
331-
None
332-
);
319+
assert_eq!(parse_contents(cfg).unwrap().virtualenvs_path, None);
333320
}
334321

335322
#[test]

crates/pet-poetry/tests/config_test.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ fn global_config_with_specific_values() {
6969
"config.toml"
7070
]))
7171
);
72-
assert!(
73-
config
74-
.clone()
75-
.unwrap()
76-
.virtualenvs_in_project
77-
.unwrap_or_default()
78-
);
72+
assert!(config
73+
.clone()
74+
.unwrap()
75+
.virtualenvs_in_project
76+
.unwrap_or_default());
7977
assert_eq!(
8078
config.clone().unwrap().virtualenvs_path,
8179
PathBuf::from("some/path/virtualenvs".to_string())
@@ -115,13 +113,11 @@ fn local_config_with_specific_values() {
115113
"poetry.toml"
116114
]))
117115
);
118-
assert!(
119-
!config
120-
.clone()
121-
.unwrap()
122-
.virtualenvs_in_project
123-
.unwrap_or_default()
124-
);
116+
assert!(!config
117+
.clone()
118+
.unwrap()
119+
.virtualenvs_in_project
120+
.unwrap_or_default());
125121
assert_eq!(
126122
config.clone().unwrap().virtualenvs_path,
127123
PathBuf::from("/directory/virtualenvs".to_string())

crates/pet-pyenv/tests/pyenv_test.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,8 @@ fn does_not_find_any_pyenv_envs_even_with_pyenv_installed() {
6060
"bin",
6161
]);
6262
let pyenv_exe = resolve_test_path(&[homebrew_bin.to_str().unwrap(), "pyenv"]);
63-
let environment = create_test_environment(
64-
HashMap::new(),
65-
Some(home.clone()),
66-
vec![homebrew_bin],
67-
None,
68-
);
63+
let environment =
64+
create_test_environment(HashMap::new(), Some(home.clone()), vec![homebrew_bin], None);
6965

7066
let conda = Arc::new(Conda::from(&environment));
7167
let locator = PyEnv::from(&environment, conda);
@@ -116,12 +112,8 @@ fn find_pyenv_envs() {
116112
]);
117113
let conda_exe = conda_dir.join("bin").join("conda");
118114

119-
let environment = create_test_environment(
120-
HashMap::new(),
121-
Some(home.clone()),
122-
vec![homebrew_bin],
123-
None,
124-
);
115+
let environment =
116+
create_test_environment(HashMap::new(), Some(home.clone()), vec![homebrew_bin], None);
125117

126118
let conda = Arc::new(Conda::from(&environment));
127119
let locator = PyEnv::from(&environment, conda);

crates/pet-python-utils/tests/sys_prefix_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ fn version_from_sys_prefix_using_version_info_format() {
3434
#[cfg(unix)]
3535
#[test]
3636
fn no_version_without_pyvenv_cfg_and_without_headers() {
37-
let path: PathBuf =
38-
resolve_test_path(&["unix", "pyvenv_cfg", "python3.9.9_without_headers"]);
37+
let path: PathBuf = resolve_test_path(&["unix", "pyvenv_cfg", "python3.9.9_without_headers"]);
3938
let version = version::from_prefix(&path);
4039
assert!(version.is_none());
4140

crates/pet/tests/ci_test.rs

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,11 @@ fn verify_validity_of_interpreter_info(environment: PythonEnvironment) {
290290
&& interpreter_info.clone().sys_prefix == "/usr/local/python/3.10.13")
291291
|| (prefix.to_str().unwrap() == "/usr/local/python/3.10.13"
292292
&& interpreter_info.clone().sys_prefix == "/usr/local/python/current"))
293-
|| (interpreter_info.clone().executable
294-
== "/home/codespace/.python/current/bin/python"
295-
&& (prefix.to_str().unwrap() == "/home/codespace/.python/current"
296-
&& interpreter_info.clone().sys_prefix == "/usr/local/python/3.10.13")
297-
|| (prefix.to_str().unwrap() == "/usr/local/python/3.10.13"
298-
&& interpreter_info.clone().sys_prefix == "/home/codespace/.python/current"))
293+
|| (interpreter_info.clone().executable == "/home/codespace/.python/current/bin/python"
294+
&& (prefix.to_str().unwrap() == "/home/codespace/.python/current"
295+
&& interpreter_info.clone().sys_prefix == "/usr/local/python/3.10.13")
296+
|| (prefix.to_str().unwrap() == "/usr/local/python/3.10.13"
297+
&& interpreter_info.clone().sys_prefix == "/home/codespace/.python/current"))
299298
{
300299
// known issue https://github.com/microsoft/python-environment-tools/issues/64
301300
} else {
@@ -367,7 +366,9 @@ fn verify_we_can_get_same_env_info_using_from_with_exe(
367366
let env = PythonEnv::new(executable.clone(), None, None);
368367
let resolved =
369368
identify_python_environment_using_locators(&env, &locators, &global_env_search_paths)
370-
.unwrap_or_else(|| panic!("Failed to resolve environment using `resolve` for {environment:?}"));
369+
.unwrap_or_else(|| {
370+
panic!("Failed to resolve environment using `resolve` for {environment:?}")
371+
});
371372
trace!(
372373
"For exe {:?} we got Environment = {:?}, To compare against {:?}",
373374
executable,
@@ -488,17 +489,19 @@ fn compare_environments(actual: PythonEnvironment, expected: PythonEnvironment,
488489
actual.version = expected.clone().version;
489490

490491
if let Some(prefix) = expected.clone().prefix {
491-
if (actual.clone().executable == Some(PathBuf::from("/usr/local/python/current/bin/python"))
492+
if (actual.clone().executable
493+
== Some(PathBuf::from("/usr/local/python/current/bin/python"))
492494
&& (prefix.to_str().unwrap() == "/usr/local/python/current"
493495
&& actual.clone().prefix == Some(PathBuf::from("/usr/local/python/3.10.13")))
494496
|| (prefix.to_str().unwrap() == "/usr/local/python/3.10.13"
495497
&& actual.clone().prefix == Some(PathBuf::from("/usr/local/python/current"))))
496-
|| (actual.clone().executable
497-
== Some(PathBuf::from("/home/codespace/.python/current/bin/python"))
498-
&& (prefix.to_str().unwrap() == "/home/codespace/.python/current"
499-
&& actual.clone().prefix == Some(PathBuf::from("/usr/local/python/3.10.13")))
500-
|| (prefix.to_str().unwrap() == "/usr/local/python/3.10.13"
501-
&& actual.clone().prefix == Some(PathBuf::from("/home/codespace/.python/current"))))
498+
|| (actual.clone().executable
499+
== Some(PathBuf::from("/home/codespace/.python/current/bin/python"))
500+
&& (prefix.to_str().unwrap() == "/home/codespace/.python/current"
501+
&& actual.clone().prefix == Some(PathBuf::from("/usr/local/python/3.10.13")))
502+
|| (prefix.to_str().unwrap() == "/usr/local/python/3.10.13"
503+
&& actual.clone().prefix
504+
== Some(PathBuf::from("/home/codespace/.python/current"))))
502505
{
503506
// known issue https://github.com/microsoft/python-environment-tools/issues/64
504507
actual.prefix = expected.clone().prefix;
@@ -513,7 +516,8 @@ fn compare_environments(actual: PythonEnvironment, expected: PythonEnvironment,
513516
.iter()
514517
.filter(|p| {
515518
// This is in the path, but not easy to figure out, unless we add support for codespaces or CI.
516-
!(p.starts_with("/Users/runner/hostedtoolcache/Python") && p.to_string_lossy().contains("arm64"))
519+
!(p.starts_with("/Users/runner/hostedtoolcache/Python")
520+
&& p.to_string_lossy().contains("arm64"))
517521
})
518522
.map(|p| p.to_path_buf())
519523
.collect::<Vec<PathBuf>>(),
@@ -526,30 +530,35 @@ fn compare_environments(actual: PythonEnvironment, expected: PythonEnvironment,
526530
.iter()
527531
.filter(|p| {
528532
// This is in the path, but not easy to figure out, unless we add support for codespaces or CI.
529-
!(p.starts_with("/Users/runner/hostedtoolcache/Python") && p.to_string_lossy().contains("arm64"))
533+
!(p.starts_with("/Users/runner/hostedtoolcache/Python")
534+
&& p.to_string_lossy().contains("arm64"))
530535
})
531536
.map(|p| p.to_path_buf())
532537
.collect::<Vec<PathBuf>>(),
533538
);
534539

535540
// if we know the arch, then verify it
536-
if expected.arch.as_ref().is_some() && actual.arch.as_ref().is_some()
537-
&& actual.arch.as_ref() != expected.arch.as_ref() {
538-
error!(
539-
"Arch mismatch when using {} for {:?} and {:?}",
540-
method, expected, actual
541-
);
542-
}
541+
if expected.arch.as_ref().is_some()
542+
&& actual.arch.as_ref().is_some()
543+
&& actual.arch.as_ref() != expected.arch.as_ref()
544+
{
545+
error!(
546+
"Arch mismatch when using {} for {:?} and {:?}",
547+
method, expected, actual
548+
);
549+
}
543550
actual.arch = expected.clone().arch;
544551

545552
// if we know the prefix, then verify it
546-
if expected.prefix.as_ref().is_some() && actual.prefix.as_ref().is_some()
547-
&& actual.prefix.as_ref() != expected.prefix.as_ref() {
548-
error!(
549-
"Prefirx mismatch when using {} for {:?} and {:?}",
550-
method, expected, actual
551-
);
552-
}
553+
if expected.prefix.as_ref().is_some()
554+
&& actual.prefix.as_ref().is_some()
555+
&& actual.prefix.as_ref() != expected.prefix.as_ref()
556+
{
557+
error!(
558+
"Prefirx mismatch when using {} for {:?} and {:?}",
559+
method, expected, actual
560+
);
561+
}
553562
actual.prefix = expected.clone().prefix;
554563

555564
assert_eq!(
@@ -596,8 +605,9 @@ fn verify_we_can_get_same_env_info_using_resolve_with_exe(
596605
locator.configure(&config);
597606
}
598607

599-
let env = resolve_environment(executable, &locators, &os_environment)
600-
.unwrap_or_else(|| panic!("Failed to resolve environment using `resolve` for {environment:?}"));
608+
let env = resolve_environment(executable, &locators, &os_environment).unwrap_or_else(|| {
609+
panic!("Failed to resolve environment using `resolve` for {environment:?}")
610+
});
601611
trace!(
602612
"For exe {:?} we got Environment = {:?}, To compare against {:?}",
603613
executable,

0 commit comments

Comments
 (0)