Skip to content

Commit

Permalink
Use the new error structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Sep 3, 2023
1 parent e1b1c97 commit 9c84798
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion crates/ruff/src/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ pub fn add_noqa_to_path(
source_type: PySourceType,
settings: &Settings,
) -> Result<usize> {
// Read the file from disk.
let contents = source_kind.source_code();

// Tokenize once.
Expand Down
11 changes: 7 additions & 4 deletions crates/ruff_cli/src/commands/add_noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ pub(crate) fn add_noqa(
.and_then(|parent| package_roots.get(parent))
.and_then(|package| *package);
let settings = resolver.resolve(path, pyproject_config);
let Ok(LintSource(source_kind)) = LintSource::try_from_path(path, source_type) else {
// TODO(dhruvmanila): Display the error to the user.
error!("Failed to extract source from {}", path.display());
return None;
let LintSource(source_kind) = match LintSource::try_from_path(path, source_type) {
Ok(Some(source)) => source,
Ok(None) => return None,
Err(e) => {
error!("Failed to extract source from {}: {e}", path.display());
return None;
}
};
match add_noqa_to_path(path, package, &source_kind, source_type, settings) {
Ok(count) => Some(count),
Expand Down

0 comments on commit 9c84798

Please sign in to comment.