Skip to content

Commit a9b6618

Browse files
committed
Nits
1 parent b7e1e64 commit a9b6618

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

crates/ty_project/src/metadata/options.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,32 +311,30 @@ impl Options {
311311
// interpreter does
312312
if let Ok(python_path) = system.env_var(EnvVars::PYTHONPATH) {
313313
for path in std::env::split_paths(python_path.as_str()) {
314-
let Some(path) = SystemPath::from_std_path(path.as_path()) else {
315-
let path = path.to_string_lossy();
316-
tracing::debug!(
317-
"Skipping `{path}` listed in `PYTHONPATH` because the path is not valid UTF-8"
318-
);
319-
continue;
314+
let path = match SystemPathBuf::from_path_buf(path) {
315+
Ok(path) => path,
316+
Err(path) => {
317+
tracing::debug!(
318+
"Skipping `{path}` listed in `PYTHONPATH` because the path is not valid UTF-8",
319+
path = path.display()
320+
);
321+
continue;
322+
}
320323
};
321324

322325
let abspath = SystemPath::absolute(path, system.current_directory());
323326

324-
if !system.path_exists(&abspath) {
325-
tracing::debug!(
326-
"Skipping `{abspath}` listed in `PYTHONPATH` because the path does not exist"
327-
);
328-
continue;
329-
}
330327
if !system.is_directory(&abspath) {
331328
tracing::debug!(
332-
"Skipping `{abspath}` listed in `PYTHONPATH` because the path is not a directory"
329+
"Skipping `{abspath}` listed in `PYTHONPATH` because the path doesn't exist or isn't a directory"
333330
);
334331
continue;
335332
}
336333

337334
tracing::debug!(
338335
"Adding `{abspath}` from the `PYTHONPATH` environment variable to `extra_paths`"
339336
);
337+
340338
extra_paths.push(abspath);
341339
}
342340
}

0 commit comments

Comments
 (0)