Skip to content

Commit

Permalink
Avoid unwrap on cache access
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jun 20, 2023
1 parent fde5dbc commit d840dd6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/ruff_cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub(crate) fn run(
package_root.to_path_buf(),
&settings.lib,
);

(&**package_root, cache)
})
.collect::<HashMap<&Path, Cache>>()
Expand All @@ -107,9 +108,7 @@ pub(crate) fn run(

let settings = resolver.resolve_all(path, pyproject_config);
let package_root = package.unwrap_or_else(|| path.parent().unwrap_or(path));
let cache = caches
.as_ref()
.map(|caches| caches.get(&package_root).unwrap());
let cache = caches.as_ref().and_then(|caches| caches.get(&package_root));

lint_path(path, package, settings, cache, noqa, autofix).map_err(|e| {
(Some(path.to_owned()), {
Expand Down

0 comments on commit d840dd6

Please sign in to comment.