Adapt is-macro for a few enums (#3182)

This commit is contained in:
Jeong YunWon 2023-02-24 13:06:56 +09:00 committed by GitHub
parent 0f37a98d91
commit da98fab4ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 110 additions and 125 deletions

View file

@ -41,23 +41,22 @@ pub fn run(
// Initialize the cache.
if cache.into() {
fn init_cache(path: &std::path::Path) {
if let Err(e) = cache::init(path) {
error!(
"Failed to initialize cache at {}: {e:?}",
path.to_string_lossy()
);
}
}
match &pyproject_strategy {
PyprojectDiscovery::Fixed(settings) => {
if let Err(e) = cache::init(&settings.cli.cache_dir) {
error!(
"Failed to initialize cache at {}: {e:?}",
settings.cli.cache_dir.to_string_lossy()
);
}
init_cache(&settings.cli.cache_dir);
}
PyprojectDiscovery::Hierarchical(default) => {
for settings in std::iter::once(default).chain(resolver.iter()) {
if let Err(e) = cache::init(&settings.cli.cache_dir) {
error!(
"Failed to initialize cache at {}: {e:?}",
settings.cli.cache_dir.to_string_lossy()
);
}
init_cache(&settings.cli.cache_dir);
}
}
}

View file

@ -28,10 +28,7 @@ pub fn run_stdin(
return Ok(Diagnostics::default());
}
}
let settings = match pyproject_strategy {
PyprojectDiscovery::Fixed(settings) => settings,
PyprojectDiscovery::Hierarchical(settings) => settings,
};
let settings = pyproject_strategy.top_level_settings();
let package_root = filename
.and_then(Path::parent)
.and_then(|path| packaging::detect_package_root(path, &settings.lib.namespace_packages));