mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-29 03:02:27 +00:00
[ty] Re-arrange "list modules" implementation for Salsa caching
This basically splits `list_modules` into a higher level "aggregation" routine and a lower level "get modules for one search path" routine. This permits Salsa to cache the lower level components, e.g., many search paths refer to directories that rarely change. This saves us interaction with the system. This did require a fair bit of surgery in terms of being careful about adding file roots. Namely, now that we rely even more on file roots existing for correct handling of cache invalidation, there were several spots in our code that needed to be updated to add roots (that we weren't previously doing). This feels Not Great, and it would be better if we had some kind of abstraction that handled this for us. But it isn't clear to me at this time what that looks like.
This commit is contained in:
parent
468eb37d75
commit
ddd4bab67c
4 changed files with 177 additions and 47 deletions
|
|
@ -433,13 +433,16 @@ pub(crate) fn dynamic_resolution_paths<'db>(
|
|||
let site_packages_dir = site_packages_search_path
|
||||
.as_system_path()
|
||||
.expect("Expected site package path to be a system path");
|
||||
let site_packages_dir = system
|
||||
.canonicalize_path(site_packages_dir)
|
||||
.unwrap_or_else(|_| site_packages_dir.to_path_buf());
|
||||
|
||||
if !existing_paths.insert(Cow::Borrowed(site_packages_dir)) {
|
||||
if !existing_paths.insert(Cow::Owned(site_packages_dir.clone())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let site_packages_root = files
|
||||
.root(db, site_packages_dir)
|
||||
.root(db, &site_packages_dir)
|
||||
.expect("Site-package root to have been created");
|
||||
|
||||
// This query needs to be re-executed each time a `.pth` file
|
||||
|
|
@ -457,7 +460,7 @@ pub(crate) fn dynamic_resolution_paths<'db>(
|
|||
// containing a (relative or absolute) path.
|
||||
// Each of these paths may point to an editable install of a package,
|
||||
// so should be considered an additional search path.
|
||||
let pth_file_iterator = match PthFileIterator::new(db, site_packages_dir) {
|
||||
let pth_file_iterator = match PthFileIterator::new(db, &site_packages_dir) {
|
||||
Ok(iterator) => iterator,
|
||||
Err(error) => {
|
||||
tracing::warn!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue