Skip to content

Commit f413e5a

Browse files
Copilotkarthiknadig
andcommitted
Fix Windows-specific clippy warnings in conditional compilation
Co-authored-by: karthiknadig <[email protected]>
1 parent badbd94 commit f413e5a

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

crates/pet-conda/src/environment_locations.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ pub fn get_known_conda_install_locations(
253253
env_vars: &EnvVariables,
254254
conda_executable: &Option<PathBuf>,
255255
) -> Vec<PathBuf> {
256-
use pet_fs::path::norm_case;
257-
258256
let user_profile = env_vars.userprofile.clone().unwrap_or_default();
259257
let program_data = env_vars.programdata.clone().unwrap_or_default();
260258
let all_user_profile = env_vars.allusersprofile.clone().unwrap_or_default();

crates/pet-windows-registry/src/environments.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ use std::{path::PathBuf, sync::Arc};
1919
#[cfg(windows)]
2020
use winreg::RegKey;
2121

22+
#[cfg(windows)]
23+
use log::{trace, warn};
24+
#[cfg(windows)]
25+
use pet_conda::utils::is_conda_env;
26+
#[cfg(windows)]
27+
use pet_fs::path::norm_case;
28+
2229
#[cfg(windows)]
2330
pub fn get_registry_pythons(
2431
conda_locator: &Arc<dyn CondaLocator>,
2532
reporter: &Option<&dyn Reporter>,
2633
) -> LocatorResult {
27-
use log::{trace, warn};
28-
2934
let mut environments = vec![];
3035
let mut managers: Vec<EnvManager> = vec![];
3136

@@ -88,10 +93,6 @@ fn get_registry_pythons_from_key_for_company(
8893
conda_locator: &Arc<dyn CondaLocator>,
8994
reporter: &Option<&dyn Reporter>,
9095
) -> LocatorResult {
91-
use log::{trace, warn};
92-
use pet_conda::utils::is_conda_env;
93-
use pet_fs::path::norm_case;
94-
9596
let mut environments = vec![];
9697
// let company_display_name: Option<String> = company_key.get_value("DisplayName").ok();
9798
for installed_python in company_key.enum_keys().filter_map(Result::ok) {

crates/pet-windows-store/src/environments.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ use std::path::PathBuf;
2121
#[cfg(windows)]
2222
use winreg::RegKey;
2323

24+
#[cfg(windows)]
25+
use crate::environment_locations::get_search_locations;
26+
#[cfg(windows)]
27+
use log::{trace, warn};
28+
#[cfg(windows)]
29+
use std::collections::HashMap;
30+
2431
#[cfg(windows)]
2532
lazy_static! {
2633
static ref PYTHON_SOFTWARE_FOUNDATION_FOLDER_VERSION: Regex = Regex::new(
@@ -92,10 +99,6 @@ impl PotentialPython {
9299

93100
#[cfg(windows)]
94101
pub fn list_store_pythons(environment: &EnvVariables) -> Option<Vec<PythonEnvironment>> {
95-
use crate::environment_locations::get_search_locations;
96-
use log::{trace, warn};
97-
use std::collections::HashMap;
98-
99102
let mut python_envs: Vec<PythonEnvironment> = vec![];
100103
let apps_path = get_search_locations(environment)?;
101104
let hkcu = winreg::RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
@@ -238,8 +241,6 @@ struct StorePythonInfo {
238241

239242
#[cfg(windows)]
240243
fn get_package_display_name_and_location(name: &String, hkcu: &RegKey) -> Option<StorePythonInfo> {
241-
use log::trace;
242-
243244
if let Some(name) = get_package_full_name_from_registry(name, hkcu) {
244245
let key = format!("Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppModel\\Repository\\Packages\\{}", name);
245246
trace!("Opening registry key {:?}", key);
@@ -258,8 +259,6 @@ fn get_package_display_name_and_location(name: &String, hkcu: &RegKey) -> Option
258259

259260
#[cfg(windows)]
260261
fn get_package_full_name_from_registry(name: &String, hkcu: &RegKey) -> Option<String> {
261-
use log::trace;
262-
263262
let key = format!("Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppModel\\SystemAppData\\{}\\Schemas", name);
264263
trace!("Opening registry key {:?}", key);
265264
let package_key = hkcu.open_subkey(key).ok()?;

crates/pet-windows-store/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ use pet_core::{os_environment::Environment, Locator};
1616
use std::path::Path;
1717
use std::sync::{Arc, Mutex};
1818

19+
#[cfg(windows)]
20+
use pet_core::python_environment::PythonEnvironmentBuilder;
21+
#[cfg(windows)]
22+
use pet_virtualenv::is_virtualenv;
23+
#[cfg(windows)]
24+
use std::path::PathBuf;
25+
1926
pub fn is_windows_app_folder_in_program_files(path: &Path) -> bool {
2027
path.to_str().unwrap_or_default().to_string().to_lowercase()[1..]
2128
.starts_with(":\\program files\\windowsapps")
@@ -61,11 +68,6 @@ impl Locator for WindowsStore {
6168

6269
#[cfg(windows)]
6370
fn try_from(&self, env: &PythonEnv) -> Option<PythonEnvironment> {
64-
use std::path::PathBuf;
65-
66-
use pet_core::python_environment::PythonEnvironmentBuilder;
67-
use pet_virtualenv::is_virtualenv;
68-
6971
// Assume we create a virtual env from a python install,
7072
// Then the exe in the virtual env bin will be a symlink to the homebrew python install.
7173
// Hence the first part of the condition will be true, but the second part will be false.

0 commit comments

Comments
 (0)