mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +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();
|
let mut package_roots: FxHashMap<&Path, Option<&Path>> = FxHashMap::default();
|
||||||
for file in files {
|
for file in files {
|
||||||
if let Some(package) = file.parent() {
|
if let Some(package) = file.parent() {
|
||||||
match package_roots.entry(package) {
|
package_roots.entry(package).or_insert_with(|| {
|
||||||
std::collections::hash_map::Entry::Occupied(_) => continue,
|
|
||||||
std::collections::hash_map::Entry::Vacant(entry) => {
|
|
||||||
let namespace_packages = if has_namespace_packages {
|
let namespace_packages = if has_namespace_packages {
|
||||||
self.resolve(file).linter.namespace_packages.as_slice()
|
self.resolve(file).linter.namespace_packages.as_slice()
|
||||||
} else {
|
} else {
|
||||||
&[]
|
&[]
|
||||||
};
|
};
|
||||||
entry.insert(detect_package_root_with_cache(
|
detect_package_root_with_cache(package, namespace_packages, &mut package_cache)
|
||||||
package,
|
});
|
||||||
namespace_packages,
|
|
||||||
&mut package_cache,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue