mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Refactor package_roots
for readability. (#10543)
This commit is contained in:
parent
c447454111
commit
7cc40d5621
1 changed files with 8 additions and 15 deletions
|
@ -180,21 +180,14 @@ impl<'a> Resolver<'a> {
|
|||
let mut package_roots: FxHashMap<&Path, Option<&Path>> = FxHashMap::default();
|
||||
for file in files {
|
||||
if let Some(package) = file.parent() {
|
||||
match package_roots.entry(package) {
|
||||
std::collections::hash_map::Entry::Occupied(_) => continue,
|
||||
std::collections::hash_map::Entry::Vacant(entry) => {
|
||||
let namespace_packages = if has_namespace_packages {
|
||||
self.resolve(file).linter.namespace_packages.as_slice()
|
||||
} else {
|
||||
&[]
|
||||
};
|
||||
entry.insert(detect_package_root_with_cache(
|
||||
package,
|
||||
namespace_packages,
|
||||
&mut package_cache,
|
||||
));
|
||||
}
|
||||
}
|
||||
package_roots.entry(package).or_insert_with(|| {
|
||||
let namespace_packages = if has_namespace_packages {
|
||||
self.resolve(file).linter.namespace_packages.as_slice()
|
||||
} else {
|
||||
&[]
|
||||
};
|
||||
detect_package_root_with_cache(package, namespace_packages, &mut package_cache)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue