Skip to content

Commit

Permalink
Use package roots rather than package members for cache initialization (
Browse files Browse the repository at this point in the history
#5233)

## Summary

This is a proper fix for the issue patched-over in
#5229, thanks to an extremely
helpful repro from @tlambert03 in that thread. It looks like we were
using the keys of `package_roots` rather than the values to initialize
the cache -- but it's a map from package to package root.

## Test Plan

Reverted #5229, then ran through the plan that @tlambert03 included in
#5229 (comment).
Verified the panic before but not after this change.
  • Loading branch information
charliermarsh authored Jun 21, 2023
1 parent f9f77cf commit 621e9ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/ruff_cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::time::Instant;
use anyhow::Result;
use colored::Colorize;
use ignore::Error;
use itertools::Itertools;
use log::{debug, error, warn};
#[cfg(not(target_family = "wasm"))]
use rayon::prelude::*;
Expand Down Expand Up @@ -80,8 +81,10 @@ pub(crate) fn run(
// Load the caches.
let caches = bool::from(cache).then(|| {
package_roots
.par_iter()
.map(|(package_root, _)| {
.values()
.flatten()
.dedup()
.map(|package_root| {
let settings = resolver.resolve_all(package_root, pyproject_config);
let cache = Cache::open(
&settings.cli.cache_dir,
Expand Down

0 comments on commit 621e9ac

Please sign in to comment.