fix: remove unused Result in uv-cache (#3875)

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
It removes the unused result when creating the Cache with the
`from_path` constructor. I don't believe it does any io operations any
more at least.
This commit is contained in:
Tim de Jager 2024-05-28 11:19:08 +02:00 committed by GitHub
parent a89e146107
commit b12b25db10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View file

@ -14,7 +14,7 @@ fn resolve_warm_jupyter(c: &mut Criterion<WallTime>) {
.build()
.unwrap();
let cache = &Cache::from_path("../../.cache").unwrap().init().unwrap();
let cache = &Cache::from_path("../../.cache").init().unwrap();
let venv = PythonEnvironment::from_virtualenv(cache).unwrap();
let client = &RegistryClientBuilder::new(cache.clone()).build();
let manifest = &Manifest::simple(vec![Requirement::from(
@ -43,7 +43,7 @@ fn resolve_warm_airflow(c: &mut Criterion<WallTime>) {
.build()
.unwrap();
let cache = &Cache::from_path("../../.cache").unwrap().init().unwrap();
let cache = &Cache::from_path("../../.cache").init().unwrap();
let venv = PythonEnvironment::from_virtualenv(cache).unwrap();
let client = &RegistryClientBuilder::new(cache.clone()).build();
let manifest = &Manifest::simple(vec![

View file

@ -39,11 +39,11 @@ impl Cache {
if no_cache {
Cache::temp()
} else if let Some(cache_dir) = cache_dir {
Cache::from_path(cache_dir)
Ok(Cache::from_path(cache_dir))
} else if let Some(project_dirs) = ProjectDirs::from("", "", "uv") {
Cache::from_path(project_dirs.cache_dir())
Ok(Cache::from_path(project_dirs.cache_dir()))
} else {
Cache::from_path(".uv_cache")
Ok(Cache::from_path(".uv_cache"))
}
}
}

View file

@ -126,12 +126,12 @@ pub struct Cache {
impl Cache {
/// A persistent cache directory at `root`.
pub fn from_path(root: impl Into<PathBuf>) -> Result<Self, io::Error> {
Ok(Self {
pub fn from_path(root: impl Into<PathBuf>) -> Self {
Self {
root: root.into(),
refresh: Refresh::None,
_temp_dir_drop: None,
})
}
}
/// Create a temporary cache directory.

View file

@ -396,7 +396,7 @@ pub fn python_path_with_versions(
temp_dir: &assert_fs::TempDir,
python_versions: &[&str],
) -> anyhow::Result<OsString> {
let cache = Cache::from_path(temp_dir.child("cache").to_path_buf())?.init()?;
let cache = Cache::from_path(temp_dir.child("cache").to_path_buf()).init()?;
let selected_pythons = python_versions
.iter()
.flat_map(|python_version| {